利用多發(fā)病例家族之單倍體資料進(jìn)行遺傳相關(guān)性研究-ppt課件_第1頁(yè)
利用多發(fā)病例家族之單倍體資料進(jìn)行遺傳相關(guān)性研究-ppt課件_第2頁(yè)
利用多發(fā)病例家族之單倍體資料進(jìn)行遺傳相關(guān)性研究-ppt課件_第3頁(yè)
利用多發(fā)病例家族之單倍體資料進(jìn)行遺傳相關(guān)性研究-ppt課件_第4頁(yè)
利用多發(fā)病例家族之單倍體資料進(jìn)行遺傳相關(guān)性研究-ppt課件_第5頁(yè)
已閱讀5頁(yè),還剩85頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、.,1,R 繪 圖 功 能,.,2,統(tǒng)計(jì)繪圖,類別資料: bar chart, pie chart 連續(xù)資料: stem-and-leaf plot, histogram, box plot, scatter plot,2,.,3,統(tǒng)計(jì)圖形(Stem-and-Leaf),Author: John W. Tukey. References: Tukey (1977) and Velleman and Hoaglin(1981). 用途與特性:莖葉圖主要是用來(lái)描述資料分佈的型態(tài),和直方圖具有一樣的性質(zhì),但卻比直方圖多了保留原始資料(keep the original data)的特性。 作法: 決

2、定stem(樹幹、主幹)的數(shù)值:可想像是直方圖的組距(如:95,stem記為9;若資料數(shù)值為985,stem記為98)。 決定leaf(樹葉):通常都是數(shù)值資料的最後一個(gè)位數(shù);定好後將資料每一筆值依序填入莖葉圖的表中(如:95,leaf記為5;若資料數(shù)值為985,leaf記為5)。 計(jì)算各組次數(shù)(frequency):填完後記錄各組的個(gè)數(shù)。,.,4,統(tǒng)計(jì)圖形(Stem-and-Leaf),優(yōu)點(diǎn)1:可呈現(xiàn)實(shí)際的觀測(cè)值。 優(yōu)點(diǎn)2:可以由此得知資料的排序(order),而有序統(tǒng)計(jì)量(order statistics)對(duì)於統(tǒng)計(jì)分析與推論上,是有很大的幫助。此外,知道資料的排序,就可得知各個(gè)資料所屬的樣

3、本百分比(sample percentiles)。 延伸圖形1:Ordered stem-and-leaf display: 將原先的莖葉圖,在樹葉部分的數(shù)值加以排序。 延伸圖形2:將原先的stem組距縮短,用符號(hào)(如:O)表示。要注意的是:資料分的組數(shù)太多,圖型會(huì)比較不平滑,可能大部分的組只有少少的觀測(cè)值,但若組數(shù)太少,所有資料又會(huì)集中在某一組;這兩種情況,都比較無(wú)法看出資料集中或是分散的趨勢(shì)。 缺點(diǎn):適合數(shù)據(jù)較少的資料。 R 指令: stem(變數(shù)名稱),.,5,統(tǒng)計(jì)圖形(Stem-and-Leaf),莖葉圖(Stem-and-Leaf),.,6,Practice,畫出data2中,身高的

4、莖葉圖,6,.,7,統(tǒng)計(jì)圖形(Box plot),用途與特性:固定資料的尺度位置,利用樣本產(chǎn)生之統(tǒng)計(jì)量(最小值minimum、第一四分位數(shù)first quartile、中位數(shù)median、第三四分位數(shù)third quartile、最大值maximum)來(lái)描繪資料的分佈。主要是利用資料尺度固定的特性,用統(tǒng)計(jì)量所在的位置來(lái)比較兩組以上資料分佈及差異,並察看資料的離散程度,圖形所呈現(xiàn)的訊息比莖葉圖或直方圖少。 作法: 確定資料的尺度。 求資料之最小值minimum(min)、第一四分位數(shù)first quartile(Q1)、中位數(shù)median(Q2)、第三四分位數(shù)third quartile(Q3)

5、、最大值maximum(max)。 第一四分位數(shù)first quartile、第三四分位數(shù)third quartile分別代表箱子的兩端,中位數(shù)median所在的位置畫一條線,將箱子切為兩半 從第一四分位數(shù)的位置畫一條線,延伸至最小值;從第三四分位數(shù)的位置畫一條線,延伸至最大值。,.,8,統(tǒng)計(jì)圖形(Box plot),其他: Interquartile range四分位距(IQR):IQRQ3-Q1 第三與第一四分位數(shù)的差距;即箱子的總長(zhǎng)度。 Outlier離群值:也可稱為極端值,若一組資料有極端值的存在,將會(huì)影響資料分佈的型態(tài),對(duì)於某些統(tǒng)計(jì)量(如:平均數(shù))也會(huì)有很大的影響。 Tukey利用I

6、QR來(lái)判別資料是否具有離群值,他訂立了幾個(gè)衡量的量與標(biāo)準(zhǔn)(Ch6.1 p.330-331): Inner fence(內(nèi)部柵欄):距離Q1及Q3 一點(diǎn)五倍IQR的位置。 Outer fence(外部柵欄):距離Q1及Q3 三倍IQR的位置。 Suspected outliers:落在inner fence與outer fence之間的資料為疑似離群值。 Outliers: 落在outer fence 之外的資料為離群值。 R指令: boxplot(變數(shù)名稱1),.,9,9,Elements of a Box Plot,盒鬚圖 (box plot),.,10,盒鬚圖 (box plot),box

7、plot(high),boxplot(c(high,200),10,.,11,Practice,畫出data2中,體重的盒鬚圖,11,.,12,分割資料繪圖,男女身高的分佈可能不同,想要將男女分開畫圖 boxplot(split(high,sex) boxplot(highsex),12,.,13,Practice,依照性別,畫出data2中,體重的盒鬚圖,13,.,14,盒鬚圖 (box plot),boxplot(high,horizontal=T),14,畫成水平的盒鬚圖,.,15,盒鬚圖 (box plot),boxplot(split(high,sex), col=c(3,4), x

8、lab=“gender”, ylab=“high”, main=Box plot),15,給男女不同的顏色,y座標(biāo)的名稱,圖形的標(biāo)題,X座標(biāo)的名稱,.,16,盒鬚圖 (box plot),boxplot(split(high,sex),col=c(red,yellow), xlab=gender, ylab=high, main=Box plot),16,除了數(shù)字之外,也可以用文字表示,.,17,Practice,依照性別,畫出data2中,體重的盒鬚圖,命名x軸為sex,y軸為weight,並用不同顏色分別男女。將此圖命名為“Box plot of weight”。,17,.,18,將圖片存

9、檔,指令: savePlot(欲儲(chǔ)存檔案名稱, type = c(wmf, emf, png, jpeg, jpg, bmp, ps, eps, pdf, ) 或者,18,.,19,統(tǒng)計(jì)圖形,盒鬚圖(Box plot) par(mfrow=c(2,2) #par指令是將圖形分成左右兩個(gè)位置;mfrow表示分割是依據(jù)列來(lái)做切割 boxplot(data$wt) #繪製weight變項(xiàng)的box plot boxplot(data$wt, horizontal=T,ylab=weight,main=Horizontal Box Plot) # horizontal=T表示畫成水平的盒子圖;main,

10、 xlab, ylab後面接的字串 分別代表圖形的標(biāo)題、x座標(biāo)、y座標(biāo)的名稱,col為圖形顏色的指令 boxplot(split(data$wt,data$sex),col=c(3,4),xlab=sex ,ylab=weight) #依照性別畫圖,並圖上顏色 boxplot(data$wtdata$sex,col=c(“red”,“yellow”),xlab=“sex” ,ylab=“weight”) #另一種依照類別(性別)畫圖的表示法 #split函數(shù)的第二個(gè)變數(shù),或是後面接的變數(shù),皆是代表要依此分群分類的資料,.,20,統(tǒng)計(jì)圖形(Box plot),.,21,Practice,請(qǐng)畫出資

11、料“airquality”中,“Temp”的盒鬚圖。 請(qǐng)根據(jù)不同月份,畫出資料“airquality”中,“Temp”的盒鬚圖。(用不同顏色代表不同月份,X軸名稱為“Month”,Y軸名稱為“Temperature”) 請(qǐng)說(shuō)明盒鬚圖的結(jié)果,21,.,22,統(tǒng)計(jì)圖形,散佈圖(Scatter plot) 用途與特性:描述兩個(gè)變數(shù)、或兩組資料之間的關(guān)係或趨勢(shì)。 指令: plot(變數(shù)名稱1, 變數(shù)名稱2),.,23,散佈圖 (Scatter plot),plot(weight,high),23,.,24,統(tǒng)計(jì)圖形(Scatter plot matrix),散佈圖矩陣 (scatter plot ma

12、trix) 當(dāng)資料有三個(gè)變數(shù)以上,可以將資料中兩兩變數(shù)之間的關(guān)係,用散佈圖矩陣呈現(xiàn)。 指令: pairs(資料檔名稱) 以鳶尾花為例 data(iris) pairs(iris),.,25,.,26,散佈圖 (Scatter plot),plot(data1),26,將data1中的所有變數(shù),兩兩配對(duì)畫出來(lái),.,27,Practice,請(qǐng)將Surgical的資料讀入R 看看共有幾個(gè)人的資料,每個(gè)人的資料收集了幾個(gè)變數(shù) 請(qǐng)畫出clot與prog的散佈圖,27,.,28,散佈圖中可以設(shè)定的參數(shù)(Scatter plot),.,29,散佈圖中可以設(shè)定的參數(shù)(Scatter plot),.,30,圖形

13、的種類(type=),plot(data2$weight,data2$high,type=p,main=type=p) plot(data2$weight,data2$high,type=l,main=type=l) plot(data2$weight,data2$high,type=b,main=type=b) plot(data2$weight,data2$high,type=o,main=type=o) plot(data2$weight,data2$high,type=h,main=type=h) plot(data2$weight,data2$high,type=s,main=typ

14、e=s),30,.,31,31,.,32,標(biāo)明線的種類 (lty=),plot(data2$weight,data2$high,type=l,lty=1,main=lty=1) plot(data2$weight,data2$high,type=l,lty=2,main=lty=2) plot(data2$weight,data2$high,type=l,lty=3,main=lty=3) plot(data2$weight,data2$high,type=l,lty=4,main=lty=4) plot(data2$weight,data2$high,type=l,lty=5,main=lt

15、y=5) plot(data2$weight,data2$high,type=l,lty=6,main=lty=6),32,.,33,33,.,34,設(shè)定點(diǎn)的型式(pch=),可選擇的型式 plot(data2$weight,data2$high,pch=1,main=pch=1) plot(data2$weight,data2$high,pch=2,main=pch=2) plot(data2$weight,data2$high,pch=3,main=pch=3) plot(data2$weight,data2$high,pch=%,main=pch=%) plot(data2$weight

16、,data2$high,pch=*,main=pch=*) plot(data2$weight,data2$high,pch=,main=pch=),34,only available on graphsheet,.,35,35,.,36,Color,36,.,37,Practice,在Surgical資料中,用三種不同的點(diǎn)畫出clot與prog的散佈圖,37,.,38,將兩變數(shù)畫在同一張圖上(Scatter plot),若想將兩個(gè)變數(shù)畫在同一張圖上,.,39,Example 1,將data1中high與weight依男女分別畫在同一張圖上,39,因?yàn)槟猩纳砀呓殪?57182,體重介於549

17、4,先畫男生的身高-體重散佈圖,X與Y的範(fàn)圍會(huì)被男生的資料決定(女生身高介於149175,體重介於4146),.,40,Example 1,plot(high_sex$M,weight_sex$M,xlim=c(140,190),ylim=c(40,100),pch=3,col=3) points(high_sex$F,weight_sex$F,pch=4,col=6),plot(high_sex$M,weight_sex$M,xlim=range(high),ylim=range(weight),pch=3,col=3) points(high_sex$F,weight_sex$F,pch=

18、4,col=6),40,.,41,加入註解,legend(X的頂點(diǎn), Y的頂點(diǎn), legend=c(欲加入的註解), pch=c(使用的點(diǎn)的型式), col=c(使用的顏色), lty=c(使用的線的種類) ) Ex: legend(150,95,legend=c(Male,Female),pch=c(3,4),col=c(3,6),41,.,42,Example 1,42,(150,95),可以很明顯看出來(lái),女生比男生輕、身高較不高 Q: 有線性關(guān)係嗎?,.,43,Example 2,43,若已知身高與體重的關(guān)係為weight=-113.5+1.05high,將這一條迴歸線加在圖中 abli

19、ne(截距,斜率) abline(-113.5,1.05,col=purple),.,44,Example 2,44,.,45,Practice,在Surgical資料中,依男女畫出clot與prog的散佈圖(gender=0: male; gender=1: gemale),男女請(qǐng)用不同顏色及標(biāo)示,並加入註解標(biāo)明男女。 假設(shè)clot與prog的關(guān)係為porg=57.75+0.95clot,請(qǐng)將此迴歸線標(biāo)示於圖上,45,.,46,Example 3,46,資料TemperatureMonth記錄臺(tái)灣26區(qū)域,一月到十二月的平均溫度 將A、B、C三地的每月平均溫度畫在同一張圖上,.,47,Pra

20、ctice,47,將D、E、F三地的每月平均溫度畫在同一張圖上 用不同顏色及線條標(biāo)明D、E、F三地,並加註解,.,48,統(tǒng)計(jì)圖形(Scatter plot),.,49,統(tǒng)計(jì)圖形(Scatter plot),.,50,統(tǒng)計(jì)圖形(Histogram),Author: William Playfair (1759-1823) 為數(shù)據(jù)圖學(xué)的先驅(qū)。 用途與特性:描述資料的分佈。 作法:決定組距(continuous data)或是類別數(shù)(categorical/ discrete data),計(jì)算各組的個(gè)數(shù),直方圖的寬度為資料的組距;高度即各組的個(gè)數(shù)、或所佔(zhàn)的百分比。 R指令: hist(變數(shù)名稱, )

21、,.,51,hist(),hist(x, breaks=Sturges, freq = NULL, col = NULL, main = paste(Histogram of , xname), xlim = range(breaks), ylim = NULL, xlab = xname, ) breaks: 設(shè)定組距 自行設(shè)定: c() 利用seq() 設(shè)定分組的組數(shù)( nclass) freq: 畫次數(shù)(T)或是相對(duì)頻率(F) xlim: X軸取值的範(fàn)圍,51,.,52,直方圖 (Histogram ),hist(high) 自動(dòng)給定組距,hist(high,breaks=c(140,1

22、55,165,170,190),52,.,53,直方圖 (Histogram ),hist(high,breaks=seq(140,190,10),hist(high,nclass=8),53,.,54,直方圖 (Histogram ),hist(high),hist(high,freq=F),54,.,55,統(tǒng)計(jì)圖形(Bar plot),用途與特性:描述資料的分佈(特別是類別資料)。 作法:寬度相同,長(zhǎng)度和已知次數(shù)成比例的長(zhǎng)方形顯示數(shù)據(jù)的統(tǒng)計(jì)圖。 指令 barplot(變數(shù)名稱) Ex: barplot(VADeaths) barplot(VADeaths, legend = rowname

23、s(VADeaths) title(main = list(Death Rates in Virginia, font = 4),.,56,.,57,Random generation from distribution,Normal distribution rnorm(n, mean=0, sd=1) Chi-square distribution rchisq(n, df , ncp=0) Student t distribution rt(n, df) F distribution rf(n, df1, df2) Binomial distribution rbinom(n, size

24、, prob) Poisson distribution rpois(n, lambda) Uniform distribution runif(n, min=0, max=1),.,58,Random generation from distribution,.,59,.,60,機(jī)率分佈相關(guān)的指令,Normal distribution 常態(tài)分佈 dnorm(x, mean=0, sd=1) x值所對(duì)應(yīng)的密度 pnorm(q, mean=0, sd=1) q值所對(duì)應(yīng)的累積機(jī)率 qnorm(p, mean=0, sd=1) 累積機(jī)率值為p所對(duì)應(yīng)的數(shù)值 rnorm(n, mean=0, sd=1

25、) 利用常態(tài)分佈產(chǎn)生n個(gè)隨機(jī)亂數(shù),.,61,繪製機(jī)率密度函數(shù)圖,#=Normal Probability distribution=# x=c(-250:250)/50 a=dnorm(x, mean = 0, sd = 1) b=dnorm(x, mean = 0, sd = 20.5) c=dnorm(x, mean = 0, sd = 0.5(0.5) dd=dnorm(x, mean = 2, sd = 1) plot(x,c,pch=+) points(x,b,pch=-,col=blue) points(x,a,col=red,pch=*) points(x,dd,pch=,col

26、=Green) legend(-5,0.55, legend=c(mean=0 var=1,mean=0 var=2,mean=0 var=0.5, mean=2 var=1),pch=c(*,-,+,), col=c(red,blue,black,Green),.,62,.,63,另一種繪製機(jī)率密度函數(shù)圖的方法,x=c(-250:250)/50 matplot(x, outer(x, c(0.5,1,2),function(x,sd)dnorm(x,0,sd), lty=1:3, type=c(l,l,l), ylab=, col=c(black,red,blue) matlines(x,

27、outer(x, c(-1,2),function(x,mu)dnorm(x,mu,1), lty=4:5, type=c(l,l,l), ylab=, col=c(green,purple) legend(1.5,0.8,c(N(0,0.5),N(0,1),N(0,2),N(-1,1),N(-2,1), lty=1:5,col=c(black,red,blue,green,purple) ),.,64,另一種繪製機(jī)率密度函數(shù)圖的方法,matplot: 將矩陣(x, y)依據(jù)行的資料,畫成圖形。 指令:matplot(x, y, 其餘圖形的設(shè)定指令);在此y是利用outer指令產(chǎn)生。 oute

28、r: 利用函數(shù)function產(chǎn)生一個(gè)矩陣,亦即生成(x, y) 指令:outer(x, y, function) function: 自訂函數(shù)。 指令:function(自訂變數(shù)名稱) 表示式或公式。 matlines: 增加不同圖形於matplot上面。 matpoints: 同上。,.,65,.,66,Example of matplot,table(iris$Species) # is data.frame with Species factor iS - iris$Species = “setosa” #邏輯變數(shù) iV - iris$Species = versicolor #邏輯變

29、數(shù) op - par(bg = “bisque”) #背景是燒陶的顏色 matplot(c(1, 8), c(0, 4.5), type= n, xlab = Length, ylab = Width, main = “Petal and Sepal Dimensions in Iris Blossoms”) #type=“n”表示座標(biāo)軸 matpoints(irisiS,c(1,3), irisiS,c(2,4), pch = c(s, S), col = c(2,4) matpoints(irisiV,c(1,3), irisiV,c(2,4), pch = (v,V), col = c(

30、2,4) legend(1, 4, c(Setosa Petals, Setosa Sepals, Versicolor Petals, Versicolor Sepals), pch = sSvV, col = rep(c(2,4), 2),.,67,繪製機(jī)率密度函數(shù)圖,繪製Beta分佈機(jī)率密度函數(shù)圖形 將Beta(1,1), Beta(1,2), Beta(1, 0.5), Beta(3,2), Beta(4,4), Beta(0.5,0.25) 繪製在同一張圖上,.,68,.,69,統(tǒng)計(jì)圖形,70,低階繪圖函數(shù),71,低階繪圖函數(shù),72,低階繪圖函數(shù),.,73,Example-text(

31、),畫出data1中,身高體重的散佈圖,並標(biāo)示出其迴歸線(weight=-113.5+1.05high),73,.,74,Practice,畫出Surgical data中, clot與prog的散佈圖,並標(biāo)示出其迴歸線(porg=57.75+0.95clot),74,.,75,Example-cex,75,設(shè)定字形大小,.,76,axis(),修改座標(biāo)軸之文字、刻度、顏色 axis(side, at = NULL, labels = TRUE, tick = TRUE, lty = solid, lwd = 1,col = NULL, .) side: 1=below, 2=left, 3=

32、above and 4=right at: 要修改的位置 labels: 修改座標(biāo)軸刻度,可以是數(shù)字或文字 tick:a logical value specifying whether tickmarks and an axis line should be drawn box(): 產(chǎn)生座標(biāo)軸框框,76,.,77,Example,par(mfrow=c(1,2) boxplot(split(clot,gender) boxplot(split(clot,gender),axes=F) axis(1,1:2,labels=c(male,female) axis(2,tick=F) box(),77,.,78,Practice,畫出Surgical data中,不同Dum1的clot之盒鬚圖(X軸之標(biāo)示為Dum1=0與Dum1=1),78,.,79,Table,計(jì)算離散型資料的次數(shù)分配表 R函數(shù):table(變數(shù)1,變數(shù)2,變數(shù)3,),79,.,80,Practice,計(jì)算Surgical data中,男女的人數(shù) 分別列出男女接受Dum1治療的人數(shù),80,.,81,長(zhǎng)條圖(bar chart),描述離散型資料之次數(shù)分配 barplot(height, width = 1, beside = FALSE, hor

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論