2013-02-25 134 views
5

附圖(曼哈頓圖)包含來自基因組和X軸的染色體位置-log(p),其中p是與點(變體)相關的p值,從那個特定的位置。 enter image description here曼哈頓圖中的峯檢測

我已經使用下述R代碼來生成它(從間隙包):

require(gap) 
affy <-c(40220, 41400, 33801, 32334, 32056, 31470, 25835, 27457, 22864, 28501, 26273, 
    24954, 19188, 15721, 14356, 15309, 11281, 14881, 6399, 12400, 7125, 6207) 
CM <- cumsum(affy) 
n.markers <- sum(affy) 
n.chr <- length(affy) 
test <- data.frame(chr=rep(1:n.chr,affy),pos=1:n.markers,p=runif(n.markers)) 
oldpar <- par() 
par(cex=0.6) 
colors <- c("red","blue","green","cyan","yellow","gray","magenta","red","blue","green",   "cyan","yellow","gray","magenta","red","blue","green","cyan","yellow","gray","magenta","red") 
mhtplot(test,control=mht.control(colors=colors),pch=19,bg=colors) 
> head(test) 
    chr pos   p 
1 1 1 0.79296584 
2 1 2 0.96675136 
3 1 3 0.43870076 
4 1 4 0.79825513 
5 1 5 0.87554143 
6 1 6 0.01207523 

我對獲得高於某一閾值的曲線的峯的座標(-log (p))。

+0

你是什麼意思的「過零」? – 2013-02-25 13:57:41

+0

「峯值的一階導數在峯值最大處有一個向下的過零點」 - 從這裏開始:http://terpconnect.umd.edu/~toh/spectrum/PeakFindingandMeasurement.htm#findpeaks;我不確定我的理解是否正確 – agatha 2013-02-25 14:03:26

+0

@agatha,這與您在[** biostars **](http://www.biostars.org/p/64416/#64558)上詢問的問題有何不同提供了一個答案..? – Arun 2013-02-25 14:34:22

回答

1

如果你希望值的第99百分位數以上的指標:

# Add new column with log values 
test = transform(test, log_p = -log10(test[["p"]])) 
# Get the 99th percentile 
pct99 = quantile(test[["log_p"]], 0.99) 

...並從原始數據test獲取值:

peaks = test[test[["log_p"]] > pct99,] 
> head(peaks) 
    chr pos   p log_p 
5  1 5 0.002798126 2.553133 
135 1 135 0.003077302 2.511830 
211 1 211 0.003174833 2.498279 
586 1 586 0.005766859 2.239061 
598 1 598 0.008864987 2.052322 
790 1 790 0.001284629 2.891222 

您可以與任何使用此閾。請注意,我還沒有計算的一階導數,看到一些指針這樣的疑問:

How to calculate first derivative of time series

計算一階導數後,你可以通過查看一階導數是時間序列點找到峯值(幾乎)爲零。確定這些峯後,您可以檢查哪些峯高於閾值。

+0

好吧,這是工作......我已經嘗試了我的數據以及...我看不到森林在樹後面。謝謝。 – agatha 2013-02-25 14:13:21

+0

然而,我仍然無法區分哪一個是峯值或不是...所以從這個結果我需要一個額外的過濾器.. p值是不夠的,因爲我不知道我正在尋找哪些點爲.. – agatha 2013-02-25 14:15:42

+0

我在我的答案中增加了更多信息。 – 2013-02-25 14:30:59

0

基於繪圖您可以使用下面的R代碼裏面找到圖形之後我的經驗,峯值協調

圖(X [,1],X [,2])

識別(X [,1],x [,2],labels = row.names(x))

請注意這裏x [,1]指的是x座標(基因座座標和x [,2]會#your -log10P值

此時使用點您的鼠標來選擇一個點,然後回車這#will給你的峯值位置,然後輸入以下代碼來獲取#coordinate

COORDS < - 定位器(TYPE =「L」)

coords