ilarsf / gwasTools

Basic and fast GWAS functions for QQ and Manhattan plots (incl. gene names)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in candidateRegions$POS[r] <- rhits$POS[which.max(rhits$LOG10P)] : replacement has length zero

sboer opened this issue · comments

I just downloaded the updated scripts (my old was probably several years old), but I have an issue with the Manhattan plot script.

The error message I get is
Error in candidateRegions$POS[r] <- rhits$POS[which.max(rhits$LOG10P)] :
replacement has length zero
Calls: ManhattanPlot
In addition: Warning message:
In as.data.table.list(x, keep.rownames = keep.rownames, check.names = check.names, :
Item 3 has 0 rows but longest item has 1; filled with NA

I have tried to run the script on two phenotypes, where it works on one, but not the other. I have gone through the files, but I am not able to find anything wrong; all columns have value within expected ranges, with no NA. They should also be sorted on chr - pos. For the phenotype giving an error, I tried with the old script I had on the cluster, and it works fine.

This is the first ten lines of the input file (which is tab-separated)
CHR POS P MAF
1 85022 0.99079011268437 0.00404269760474563
1 135195 0.52322468045994 0.00930232927203178
1 233476 0.44981101380145 0.00814521033316851
1 233582 0.286454369491075 0.00564469257369637
1 554968 0.294178441484736 0.00653086602687836
1 569994 0.615267901422401 0.00595780368894339
1 574151 0.622304870569572 0.0127126947045326
1 581812 0.302093715615789 0.0190441608428955
1 648843 0.643641380536429 0.00501822307705879

This is the code I am running: Rscript ManhattanPlot.r --input test.txt --prefix test --chr CHR --pos POS --pvalue P

It guess it must be something wrong with the input file, that is tolerated by the old script, but not the new one, but I have not been able to figure out by looking through the code or the inputfile...

Do you have any ideas what your updated script is not tolerating?
Thankful for any help!

Edit: The only difference I could find between the two phenotypes, is that the phenotype that did not work, did not have any significant SNPs. For the file where the script worked, I removed the significant SNP(s). Then running the Manhattan plot script again I get the error. Could it be a bug in the script that requires the resultfile to contain significant SNPs?

Hi Sigrid,

I think I fixed the issue you observed. Could you please download the latest version and try again?

Thanks,
Lars

Hi!

I just tried the new script, but I got this error message, both for phenotypes with and without significant hits:

Error` in nrow(hits) : object 'hits' not found
Calls: ManhattanPlot -> nrow
Execution halted

Thanks,
Sigrid

I forgot one line and just added it. Should have tested it first. Please try again

Now it seems to work, thanks a lot!