Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a new GDS node to my existing GDS file #103

Open
GabryS3 opened this issue Nov 8, 2023 · 0 comments
Open

Adding a new GDS node to my existing GDS file #103

GabryS3 opened this issue Nov 8, 2023 · 0 comments

Comments

@GabryS3
Copy link

GabryS3 commented Nov 8, 2023

Dear Dr Zheng,
I am trying to add a node to my GDA file, but I am struggling a lot with it, so I would love some advice and help with this.

I obtained my GDS file by converting a "genlight" object (R package adegenet/dartR) into a GDS file for SNPRelate with the dartR::gl2gds() function.
However, the GDS file has no sample annotation, and I would like to add this as I would like to run KING robust incluging the family.id field (geographic population or hybrids/pure individuals categories).

I have read your SNPRelate tutorial, but I am encountering troubles adding a gds node to my GDS object.
Here is the code I used:

"
mydataset_GDS = gl2gds(
mydataset_genlight,
outfile = "mydataset_GDS.gds",
outpath = getwd(),
snp_pos = "0",
snp_chr = "0",
chr_format = "character",
verbose = 5)

sample.annotation = mydataset_genlight@other$ind.metrics # contains all individual metrics in a dataframe format

class(sample.annotation) # data.frame

    mydataset_GDS_File= snpgdsOpen("C:/gabry/analysis/mydataset_GDS.gds", readonly=FALSE, allow.duplicate=FALSE, 
                                                              allow.fork=TRUE)
    
    class(mydataset_GDS_File) # "SNPGDSFileClass" "gds.class"     
    
    get.attr.gdsn(index.gdsn(mydataset_GDS_File, "snp.chromosome")) # NULL
    get.attr.gdsn(index.gdsn(mydataset_GDS_File, "sample.annotation")) #   No such GDS node "sample.annotation"!

    
    add.gdsn(mydataset_GDS_File, "sample.annotation", sample.annotation)
        **# Error in add.gdsn(Blacktip_Rep0.98_test_5genotypes_GDS_File, "sample.annotation",  : 
        # Invalid GDS node object (it was unloaded or deleted).**
    "

I don't know how else to include the sample/individuals metadata in the GDS file. I would really appreciate some help!
Thanks a lot!
Best,
Gabriella

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant