HannahVMeyer / PhenotypeSimulator

Other
28 stars 7 forks source link

getCausalSNPs from oxgen format #9

Closed blairzhang126 closed 5 years ago

blairzhang126 commented 5 years ago

I have trouble to get this function work for oxgen format. My command is:

"causalSNPs <- getCausalSNPs(N=6000, NrCausalSNPs=10, chr=22,genoFilePrefix="genocase", genoFileSuffix=".gen", format="oxgen", NrSNPsOnChromosome=119317)"

The error message I got is "Error in .rowNamesDF<-(x, value = value) : invalid 'row.names' length". My guess is that if I use suffix as ".gen" it cannot read ".sample" file so that the row.names is invalid. However, I cannot proceed without suffix flag. Any idea?

Any feedback would be greatly appreciated.

Thanks so much Hannah. -Blair

HannahVMeyer commented 5 years ago

Hi Blair,

at the step that I suspect it is failing, the sample IDs (contained in the .sample) file are not needed yet, so this won't be the issue.

Can you paste the first 10 columns and lines of the file that is failing ie from geno_case_chr22.gen?

blairzhang126 commented 5 years ago

Thank you so much for the quick reply Hannah.

My first few lines look like this (I added "22-" after it's not working on the original hapgen2 output): 22-snp_0 rs62224609 14431249 T C 1 0 0 1 0 0 1 0 0 0 1 0 1 0 0 1 0 0 1 0 0 22-snp_1 rs11089130 14431347 G C 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 22-snp_2 rs11089134 14431497 A G 1 0 0 0 1 0 0 1 0 1 0 0 1 0 0 1 0 0 1 0 0 22-snp_3 rs2096600 14431968 C A 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 22-snp_4 rs9604696 14431994 C T 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 22-snp_5 rs4965031 14432080 G A 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 0 22-snp_6 rs2843214 14432239 A G 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 0 22-snp_7 rs4965018 14432361 A G 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 0 22-snp_8 rs2078643 14432513 G C 1 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 22-snp_9 rs738829 14432618 G A 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1

blairzhang126 commented 5 years ago

I got it working when I transform my file format into the space-delimited format and follow the example you gave for .csv file. So don't worry about it if it requires a lot of time and work to get it working on oxgen format if I'm the only person who got this error. Thanks again for your help Hannah. Feel free to keep me posted on any thing related to this.

HannahVMeyer commented 5 years ago

I've just made changes in the develop branch. Could you check if it works after you do: devtools::install_github('HannahVMeyer/PhenotypeSimulator', ref='dev’)

Thanks

blairzhang126 commented 5 years ago

Hi Hannah, I got an error: "Error in getCausalSNPs(N = 100, NrCausalSNPs = 10, chr = 22, genoFilePrefix = "testtime", : object 'samples' not found".

blairzhang126 commented 5 years ago

My script: "causalSNPs <- getCausalSNPs(N=100, NrCausalSNPs=10, chr=22,genoFilePrefix="testtime", genoFileSuffix="_100_out.controls.gen",NrSNPsOnChromosome = 119316, format="oxgen")"

mahideel commented 5 years ago

Hi Hannah and Blair,

I got a similar error when running runSimulation.

My script: sim <- runSimulation(N=2000, P=1, chr = c(1,3,5), genoFilePrefix = genoFilePrefix, genoFileSuffix = genoFileSuffix, genoDelimiter=" ", cNrSNP = 5, distBetaGenetic = "norm", mBetaGenetic = 1.00, sdBetaGenetic = 0.99, genVar = 0.1, h2b = 0, theta = 0, phi=1, pIndependentGenetic=1, verbose=TRUE, sampleID="id1_", format="oxgen")

Error I get: Error in row.names<-.data.frame(*tmp*, value = value) : invalid 'row.names' length

When I did the debugging, it seemed like the error came from this function: rownames(causalSNPsChr) <- paste(causalSNPsChr[, 1:5], collapse = "-")

Any help is greatly appreciated.

Kind regards, Novia

mahideel commented 5 years ago

PS. This error never happened in the past. Last time I ran PhenotypeSimulator was in mid-Dec 2018 (can't remember the date exactly).

HannahVMeyer commented 5 years ago

Apologies for the late reply - I will look into it this week. Thanks

HannahVMeyer commented 5 years ago

This fixed now on github version 0.3.2. I will keep the issue open until this has been updated on CRAN.

HannahVMeyer commented 5 years ago

Latest release including this fix on CRAN (v0.3.3), closing this now.