how to save results meta data to file
1
@aa611017
Last seen 2.7 years ago
United States
when I save my result to disk. I would like to add a couple of header lines. When I display the results in RStudio I see the following
log2 fold change (MLE): sampleType ex0 vs bulk
Wald test p-value: sampleType ex0 vs bulk
DataFrame with 13002 rows and 6 columns
What function produced this text?
I plan to use
cat(metadata, outfile)
write(results, outfile, append)
is there a better way?
Kind regards
Andy
DESeq2
• 1.1k views
@aa611017
Last seen 2.7 years ago
United States
To make my output files self-describing I add the following code
retList <- selfDescribingResults(salmonMockOutput, expectedMockDF)
result <- retList[["result"]]
dds <- retList[["dds"]]
outfile <- "./output/selfDescribingResultsDESeqTestResult.csv"
print( sprintf("saving: %s", outfile) )
descriptionList <- result@elementMetadata@listData[["description"]]
cat( sprintf("%s \n", descriptionList[[1]]), file=outfile)
for (i in 2:length(descriptionList)) {
txt <- sprintf( "%s \n", descriptionList[[i]] )
cat( txt, file=outfile, append=TRUE)
}
txt <- sprintf( "design: %s \n", format(design(dds)))
cat( txt, file = outfile, append = TRUE)
write.table( result,
append=TRUE,
file=outfile)
The final output looks like
$ cat output/selfDescribingResultsDESeqTestResult.csv
mean of normalized counts for all samples
log2 fold change (MLE): treatment kras vs ctrl
standard error: treatment kras vs ctrl
Wald statistic: treatment kras vs ctrl
Wald test p-value: treatment kras vs ctrl
BH adjusted p-values
design: ~treatment
"baseMean" "log2FoldChange" "lfcSE" "stat" "pvalue" "padj"
0 NA NA NA NA NA
34.7850542618522 1.75223301400487e-06 0.792241255192021 2.21174169171507e-06 0.999998235285452 0.999998235285452
31.6227766016838 0.584964450108051 1.00512453712141 0.581982061430254 0.56057876394163 0.999998235285452
41.1096095821889 1.77308119366584e-06 0.783192826262264 2.26391398670971e-06 0.999998193657983 0.999998235285452
44.2718872423573 1.78360849630579e-06 0.779577033726344 2.28791821608728e-06 0.999998174505379 0.999998235285452
47.4341649025257 1.79409460171499e-06 0.776414037778314 2.31074467284071e-06 0.999998156292502 0.999998235285452
50.5964425626941 1.80435965275494e-06 0.773593953855382 2.33243763574224e-06 0.999998138984021 0.999998235285452
171.342744553457 -0.00798577997492075 0.74248829012135 -0.0107554288480638 0.991418574826439 0.999998235285452
your mileage may vary
Andy
Login before adding your answer.
Traffic: 818 users visited in the last hour
A bit shorter code is to use
mcols
. See here:https://bioconductor.org/packages/release/bioc/vignettes/DESeq2/inst/doc/DESeq2.html#access-to-all-calculated-values
Thank you for this information. I was also facing the same issues on my BPO file. When I try your method, then all problems have been solved. Then you again always be happy.