stephenturner / qqman

An R package for creating Q-Q and manhattan plots from GWAS results
http://cran.r-project.org/web/packages/qqman/
GNU General Public License v3.0
156 stars 91 forks source link

Allow character values for chromosomes #35

Closed stephenturner closed 6 years ago

stephenturner commented 9 years ago

From a user:

We had to face the problem that the chromosome names contain characters (e.g. 1A, 1B, 1D, …), so we had to change the code of your manhattan function, so we can get the original chromosome names work with it. Now we thought of sending you our changes, maybe you’ll give it a try to change your code as well, because we think we aren’t the only ones facing this problem. See following an extract of our changed version. You can see, that we enumerate the chromosome column and replace the entries for the plotting:

manahattan<-function(x, chr = "chrom", bp = "baseP", p = "pvals", snp="snps",
          col = c("gray10", "gray60"), main=main,
          suggestiveline = -log10(tresh), genomewideline =FALSE,
          highlight = NULL, logp = TRUE, ...)
{
   chrlabs = unique(x[[chr]])
   for( i in 1:length(chrlabs)) {
                   x[x[[chr]] == chrlabs[i],chr]=i
   }
   x[[chr]] <- as.numeric(x[[chr]])

    CHR = BP = P = index = NULL
    if (!(chr %in% names(x)))
        stop(paste("Column", chr, "not found!"))
# ...
DenaFrancis commented 8 years ago

Hi Stephen, Making the chr accepts letters as well as numbers would be really great for me since I am working in Drosophila and there are only 4 chromosomes and usually they have a left and right side, eg 2L and 3R. I am new to R and coding and I was wondering if you will make this change a part of the qqman package? Thanks, Dena

stephenturner commented 8 years ago

Just change the chrlabs argument. See ?manhattan.