Hello,
I am trying to run plotManhattan but keep encountering a cryptic error... I am sure this error is not related to the fact that I am slightly abusing plotManhattan - I am not trying to plot SNPs but rather entire genes (i.e. start and end positions are different).
Here is the data:
> head(test)
chr start end id pvalue
1 chr2L 10973443 10975293 FBgn0000018 0.4516569
2 chr2L 6041181 6046050 FBgn0000052 0.2913911
3 chr2L 7014623 7023898 FBgn0000053 0.3965246
4 chr2L 14615552 14618902 FBgn0000056 0.9398898
5 chr2L 19110154 19114110 FBgn0000075 0.8430910
6 chr2L 2156484 2178754 FBgn0000097 0.7744837
> str(test)
'data.frame': 10000 obs. of 5 variables:
$ chr : chr "chr2L" "chr2L" "chr2L" "chr2L" ...
$ start : int 10973443 6041181 7014623 14615552 19110154 2156484 12175004 18078269 10997819 13821248 ...
$ end : int 10975293 6046050 7023898 14618902 19114110 2178754 12313438 18081307 11001476 13823979 ...
$ id : chr "FBgn0000018" "FBgn0000052" "FBgn0000053" "FBgn0000056" ...
$ pvalue: num 0.452 0.291 0.397 0.94 0.843 ...
> table(test$chr)
chr2L chr2R chr3L chr3R chr4 chrX chrY
1870 2037 1915 2449 67 1630 2
> test.genome
chr length
1 chr2L 23513712
2 chr2R 25286936
3 chr3L 28110227
4 chr3R 32079331
5 chr4 1348131
6 chrX 23542271
7 chrY 3667352
> str(test.genome)
'data.frame': 7 obs. of 2 variables:
$ chr : chr "chr2L" "chr2R" "chr3L" "chr3R" ...
$ length: int 23513712 25286936 28110227 32079331 1348131 23542271 3667352
But then:
> library("Sushi")
> plotManhattan(bedfile=test,genome=test.genome,pvalues=test$pvalue,cex=0.75)
Error in `[<-.data.frame`(`*tmp*`, , 1, value = "chr") :
replacement has 1 row, data has 0
I cannot figure out what is wrong with the chr
variable. I tried changing the variable to factors, changing chromosome names to numeric values, tried removing the string "chr" before the actual chromosome number and I tried to turn this data into fake SNP data (start and end position were the same). I keep getting the same error. I noticed as well that there is a similar issue with qqman
package (http://www.gettinggeneticsdone.com/2011/04/annotated-manhattan-plots-and-qq-plots.html) and think maybe it's a bug, but hope it's just something stupid on my part. If not, and if anyone has a better way of doing what I want to do, please let me know.
yot
I think its just the way how the function is written. I tried to find the problem and the error is coming from the header of your genome file. If you read the genome file again and add
header=F
or manually put the colnames toV1
andV2
(default names). The error will go away, but you might run into something else. Hope it works out for you!Thanks for the tip! It didn't work right out of the box, but after I changed column names to default I had to change chromosome names (in the bedfile the chromosome names must be in the format of "chrN" and not just "N"). They also need to be as factors, but plotManhattan turns them into factors anyway. So, after I changed the column names and added "chr" to my chromosome numbers - it worked! I only wish you'd given your comment as a reply, I could reward you with riches of thumbs up or karma points or whatever it is that people collect over here :-)