zhengxwen / SNPRelate

R package: parallel computing toolset for relatedness and principal component analysis of SNP data (Development version only)
http://www.bioconductor.org/packages/SNPRelate
101 stars 25 forks source link

add.gdsn not work correctly #13

Closed lian0090 closed 9 years ago

lian0090 commented 9 years ago

When I try to add some data into my gdsn object, R reports this error add.gdsn(genofile, "try", "da") : Invalid argument

zhengxwen commented 9 years ago

Can you show me the complete code?

jliberto2 commented 8 years ago

Hi Zhengxweng, I hope it is okay to post this on a closed issue, but I am I am also having the same issue. I am currently working with a small sample dataset (10 SNPs and 5 individuals) and working my way through the PCA for SNP genotype data pipeline posted here. The code seems to work just fine until I try to add my new data frame in. I will post my code below:

snpgdsVCF2GDS("snps.first30.5ind.vcf","snps.first30.5ind.gds",verbose=T)
genofile=openfn.gds("snps.first30.5ind.gds")
RV <- snpgdsPCA(genofile, num.thread=2)
samp.annot<-data.frame(pop.group = c("EUR","EUR","EUR","EUR","EUR"))
add.gdsn(genofile, "sample.annot", samp.annot)

I get this as the following error:

Error in add.gdsn(genofile, "sample.annot", samp.annot) : 
  Invalid argument
zhengxwen commented 8 years ago

Please open the GDS file with a writable option:

genofile = openfn.gds("snps.first30.5ind.gds", readonly=FALSE)

and,

add.gdsn(genofile, "sample.annot", val=samp.annot)

Also please try installing the latest version of gdsfmt and SNPRelate.

jliberto2 commented 8 years ago

Thank you for your quick response. Updating my R to version 3.4.2 allowed me to update SNPRelate to 1.4.2 and gdsfmt to 1.6.2, which was the key to my problem. I hope you have a very nice evening and again, thank you for your help.