ThomasChln / snpclust

Single nucleotide polymorphism unsupervised clustering
GNU General Public License v3.0
4 stars 0 forks source link

Error in snpclust function #1

Open parikhhm opened 5 years ago

parikhhm commented 5 years ago

Dear Dr. Charlon,

I hope you are doing well.

I am referring to your article and associated GitHub page for SNPClust https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0160270 https://github.com/ThomasChln/snpclust

I am trying to use snpclust for our SNP data in a plink binary format. I am getting an error related to the snpclust function as follows:

snpclust_object <- snpclust(gds = "snp_gwas.gds", n_axes = 20) Error in gds_to_bed(normalizePath(gds)) : trying to get slot "data" from an object of a basic class ("NULL") with no slots In addition: Warning message: In SNPRelate::snpgdsGDS2BED(gdsobj, name, verbose = FALSE) : There is no allele information in the GDS file. ``A/B'' is used for the last two columns.

Can you please look at the error according to your convenience?

I truly appreciate your kind help.

Thanks,

Hemang

ThomasChln commented 5 years ago

Hello,

Thank you for your interest, I made a few modifications these last months which broke a few things. I now pushed a clean release, v0.2, so please update your package and let me know if it fixes your issue.

Best,

parikhhm commented 4 years ago

Dear Dr. Charlon,

I hope you and your family are doing well.

I am trying to run snpclust using plink files and I am getting a similar error:

Error in genotype_data_subset(gdata, snps_idx, scans_idx) : trying to get slot "data" from an object of a basic class ("NULL") with no slots

Can you please look at the error? Here is the R code and its output for your reference.

# R code
library(gdsfmt)
library(SNPRelate)
library(snpclust)

bed.fn <- "chr20.bed"
fam.fn <- "chr20.fam"
bim.fn <- "chr20.bim"

snpgdsBED2GDS(bed.fn, fam.fn, bim.fn, "testing.gds", snpfirstdim = NA, cvt.chr = "int", cvt.snpid = "int", verbose = TRUE)
snpgdsSummary("testing.gds")
snpclust(paths = "/tmp/compare", gds = "testing.gds", subsets = "", n_axes = 100, n_cores = 4,  only_pca = FALSE, snprelate_qc = TRUE)
# R output

> bed.fn <- "chr20.bed"
> fam.fn <- "chr20.fam"
> bim.fn <- "chr20.bim"
>
> snpgdsBED2GDS(bed.fn, fam.fn, bim.fn, "testing.gds", snpfirstdim = NA, cvt.chr = "int", cvt.snpid = "int", verbose = TRUE)
Start snpgdsBED2GDS ...
        BED file: "chr20.bed" in the SNP-major mode (Sample X SNP)
        FAM file: "chr20.fam", DONE.
        BIM file: "chr20.bim", DONE.
Thu Apr 30 10:39:18 2020        store sample id, snp id, position, and chromosome.
        start writing: 8227 samples, 12617 SNPs ...
        Thu Apr 30 10:39:18 2020        0%
        Thu Apr 30 10:39:19 2020        100%
Thu Apr 30 10:39:19 2020        Done.
Optimize the access efficiency ...
Clean up the fragments of GDS file:
    open the file 'testing.gds' (24.8M)
    # of fragments: 43
    save to 'testing.gds.tmp'
    rename 'testing.gds.tmp' (24.8M, reduced: 276B)
    # of fragments: 20
>
> snpgdsSummary("testing.gds")
Some of 'snp.allele' are not standard (e.g., D/I).
The file name: /home/parikhh/tmp/compare/testing.gds
The total number of samples: 8227
The total number of SNPs: 12617
SNP genotypes are stored in SNP-major mode (Sample X SNP).
The number of valid samples: 8227
The number of biallelic unique SNPs: 12576
>
> snpclust(paths = "/tmp/compare", gds = "testing.gds", subsets = "", n_axes = 100, n_cores = 4,  only_pca = FALSE, snprelate_qc = TRUE)
Error in genotype_data_subset(gdata, snps_idx, scans_idx) :
  trying to get slot "data" from an object of a basic class ("NULL") with no slots
ThomasChln commented 4 years ago

Hello Hemang,

Thanks, I think your problem is due to empty Scan and Snp annotation data frames. I am preparing a new release that will manage it directly.

All is fine here thanks, hope the same for you. Best,

ThomasChln commented 4 years ago

Hello Hemang,

I have now pushed a clean v0.3 release that should fix your issue. Let me know if it's all good.

Best,