Question: how to save subsetted GDS file
gravatar for Adrienne Stilp
17 months ago by
United States
Adrienne Stilp30 wrote:

Asked by a user via email:


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 • 298 views
ADD COMMENTlink modified 17 months ago by Stephanie M. Gogarten710 • written 17 months ago by Adrienne Stilp30

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?


ADD REPLYlink written 17 months ago by Adrienne Stilp30
Answer: how to save subsetted GDS file
gravatar for Stephanie M. Gogarten
17 months ago by
University of Washington
Stephanie M. Gogarten710 wrote:

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 COMMENTlink modified 17 months ago • written 17 months ago by Stephanie M. Gogarten710

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 REPLYlink written 17 months ago by cwaters80
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 156 users visited in the last hour