'How do I combine MAF files with clinical data to perform clinical enrichment analysis?

I want to read into a list of MAF files and combine it with the clinical data and then perform clinical enrichment analysis.

library(maftools)

# Load MAF files (By default, silent mutations are discarded using removeSilent=TRUE; Hence, silent mutations do not need to be subsetted in Question 2)
d <- merge_mafs(lapply(Sys.glob("mafs/Patient*.maf"), read.maf))

# Load sample information
c <- read.table(file="sample-information.tsv", sep="\t", header=T)  

# Combine MAF and sample info
d <- read.maf(maf=d, clinicalData=c)

Traceback:

-Reading Error in file.info(file) : invalid filename argument

# Clinical enrichment

response.ce = clinicalEnrichment(maf=d, clinicalFeature="Response")

Error in [.data.table(getClinicalData(x = maf), , c("Tumor_Sample_Barcode", : column(s) not found: Response

Dataset: https://drive.google.com/file/d/1pX78BUsh__VIVg4tJNChCA5b8h4tkjj-/view

r


Solution 1:[1]

Perhaps try to read the sample information first, then each time you read in a single maf file (i.e. within the lapply), indicate the clinicalData argument as sample_info. Like this:

# Get the sample information
sample_info = read.table(file="sample-information.tsv", sep="\t", header=T)

# lapply over all the maf file, each indicating clinicalData=sample_info
d = merge_mafs(lapply(dir("mafs/",full.names = T), read.maf, verbose=F, clinicalData=sample_info))

# Get the response.ce
response.ce = clinicalEnrichment(maf = d,clinicalFeature = "Response")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 langtang