how to save subsetted GDS file
2
0
Entering edit mode
@adrienne-stilp-6412
Last seen 5.2 years ago
United States

Asked by a user via email:

Hello,

I'm attempting to use the GWAStools package and unfortunately have not had much luck. I have a GDS object and would like to subset that GDS object for specific individuals, and then save the subsetted GDS object permanently in my directory. I'm attempting to use the gdsSubset function but do not know how to save the subsetted GDS file as a permanent file in my working directory. I would greatly appreciate any insight you may have.  I'm including my code below.

Thank you for your help,

Charlie Waters

# Create a new GDS file containing only the individuals for which we have phenotype and other meta data

# read in meta data for the individuals
sample_metadata <- read.csv("Scan_annotation_data_object.csv", header=T)

# First make vector of sample IDs
sampleIDs <- sample_metadata$scanID

# Write path to full GDS file. Not sure why it needs the path instead of the actual GDS object in R but oh well.
gdsfile <- "C:/Users/Waters/Dropbox (MERLAB)/Puerto_Rico_AD_GWAS/PR5geno.gds"

# Create temporary file...only way I can get the function to work
PR5geno_subset <- tempfile()

gdsSubset(gdsfile, PR5geno_subset, sample.include = sampleIDs)
gdsSubsetCheck(gdsfile, PR5_genofile_subset, sample.include = sampleIDs)

# Can't move forward. The example doesn&#39;t give any insight into how I can save the subset as a new GDS file.
gwastools • 2.3k views
ADD COMMENT
0
Entering edit mode

Hi Charlie,

The PR5geno_subset gds file should contain the subset of samples that you requested. Can you provide more infomartion about the problem you're encountering? Are you getting an specific error message?

Adrienne

ADD REPLY
0
Entering edit mode
@stephanie-m-gogarten-5121
Last seen 5 months ago
University of Washington

I think Charlie was expecting gdsSubset to return a new GDS object that he/she can then save, but that is not how the function works. The second argument is the file name of the subsetted GDS file, which is already created by the function. In the example provided, PR5geno_subset contains a character string with the path to the new GDS file. Since it was assigned the output of tempfile(), that file is in the temporary directory. To create the subsetted file in the working directory instead, you would do the following:

newfile <- "PR5geno_subset.gds"
gdsSubset(gdsfile, newfile, sample.include = sampleIDs)

 

ADD COMMENT
0
Entering edit mode

Hi Stephanie and Adrienne,  thanks so much for your help!  I was indeed hoping that the gdsSubset would return a new GDS object. Further, the tempfile() function was proving very problematic for me because I could not physically locate the actual temporary directory (user error, I'm sure).  But in the end I solved the issue by manually creating a blank GDS file, and then setting the new file directory to the one that I manually created (so almost identical to what Stephanie proposed).  Perhaps the example in the GWAStools manual can be expanded to also include the solution that Stephanie proposed above. Thanks! Charlie Waters

ADD REPLY

Login before adding your answer.

Traffic: 517 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6