TCGABioLinks getManifest() function. How to alter saved file name?
1
0
Entering edit mode
3.8 years ago
ivykosater • 0

In the TCGABioLinks R package there is a function called getManifest() which allows you to download queries samples manifest files. I have two datasets that I'm trying to pull. One is a set of tumor samples with a specific mutation, the other is the set of samples without said mutation.

What I've done so far is to query these both using the GDCquery() function. My code is below

query <- GDCquery(project = "TCGA-BRCA", 
                 data.category = "Transcriptome Profiling",
                 data.type = "Gene Expression Quantification", 
                 workflow.type = "HTSeq - FPKM",
                 barcode = samples$V2)

# Samples without mutation
control_query <- GDCquery(project = "TCGA-BRCA", 
data.category = "Transcriptome Profiling", 
data.type = "Gene Expression Quantification", workflow.type = "HTSeq - FPKM", barcode = control$V2)

#Download manifest files
 getManifest(query, save=TRUE)
 getManifest(control_query, save=TRUE)

However, the problem lies with the fact that the saved manifest file is named gdc-manifest.txt, and there is no argument to change file name, so when I try to download two manifest files, one gets overwritten. How would I go about changing the file name?

TCGA R Bioconductor • 1.3k views
ADD COMMENT
1
Entering edit mode

The code for getManifest is:

getManifest <- function(query, save = FALSE) {
    manifest <- query$results[[1]][,c("file_id","file_name","md5sum","file_size","state")]
    colnames(manifest) <- c("id","filename","md5","size","state")
    if(save)  {
        fname <- "gdc_manifest.txt"
        write_delim(manifest,fname,delim = "\t")
        file <- file.path(getwd(),fname)
        message("Manifest saved as: ", file)
    }
    return(manifest)
}

Maybe overwrite it with a modified version so it can write to a custom file name?

ADD REPLY
1
Entering edit mode
3.6 years ago
Jn Rmro ▴ 10

Perhaps you can write a custom modified function, as Ram suggested, to change the file name:

getManifest.mod <- function(query, save = FALSE, save.dir = "gdc_manifest.txt") {
manifest <- query$results[[1]][,c("file_id","file_name","md5sum","file_size","state")]
colnames(manifest) <- c("id","filename","md5","size","state")
if(save)  {
    fname <- save.dir
    write_delim(manifest,fname,delim = "\t")
    file <- file.path(getwd(),fname)
    message("Manifest saved as: ", file)
}
return(manifest)
}

Without changing too much of the original code, just be sure to set your working directory to the path where you want the file to save. Change save.dir from the default "gdc_manifest.txt" to the file name you want.

ADD COMMENT

Login before adding your answer.

Traffic: 2662 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