ReportingTools package
1
0
Entering edit mode
Jason Hackney ▴ 160
@jason-hackney-5882
Last seen 10.3 years ago
Hi Hena, > I am using the package ReportingTools and would like to know if is it possible to publish t statistics in the report for differential expression analysis using limma? This depends quite a bit on what version of ReportingTools you are using. For the current release version, there are a couple of ways to do this. The most straightforward way is to write a custom function and override the toReportDF method for MArrayLM objects. There is a helper function in the package, ReportingTools:::.marrayLM.to.data.frame that might serve as a template for getting the t-statistic. Here's kind of a rough sketch that I would use, drawn heavily from that helper function, but missing some error checking: my.df.fn <- function (object, eSet = NULL, n = 1000, pvalueCutoff = 0.01, lfc = 0, adjust.method = "BH", coef = NULL, make.plots = FALSE, factor = NULL, ...) { dat <- topTable(object, number = n, p.value = pvalueCutoff, lfc = lfc, coef = coef, adjust.method = adjust.method) selection <- rownames(dat) padj <- apply(object$p.value, 2, p.adjust, method = adjust.method) padj <- padj[selection, coef] object <- object[selection, coef] if (!missing(eSet) & !is.null(eSet)) { eSet <- eSet[selection, ] fdata <- ReportingTools:::annotate.genes(featureNames(eSet), annotation(eSet), keytype = "PROBEID", cols = list(ProbeId = "PROBEID", EntrezId = "ENTREZID", Symbol = "SYMBOL", GeneName = "GENENAME")) } ret <- data.frame(fdata, Image = rep(NA, nrow(fdata)), object$t, padj, stringsAsFactors = FALSE) t.cols <- (ncol(fdata) + 2):(ncol(fdata) + 1 + ncol(object$t)) colnames(ret)[t.cols] <- paste(colnames(object), "t-Statistic") pv.cols <- (ncol(fdata) + ncol(object$coef) + 2):ncol(ret) colnames(ret)[pv.cols] <- paste(colnames(object), "Adjusted p-Value") return(ret) } Once you have your function for coercing an MArrayLM object to a data.frame, then you can pass it to the publish call in the .toDF argument: publish(my.fit, my.report, my.eset, n = 100, coef = 2, factor = my.eset$groups, .toDF = my.df.fn) The rest should work as expected. Let me know if that helps, or if you have any further problems. Cheers, Jason > Thanks! > > > > Hena Ramay, PhD > Bioinformatician > Swiss Institute of Bioinformatics > Lausanne, Switzerland -- Jason A. Hackney, Ph.D. Bioinformatics and Computational Biology Genentech hackney.jason@gene.com 650-467-5084 [[alternative HTML version deleted]]
ReportingTools ReportingTools • 1.2k views
ADD COMMENT
0
Entering edit mode
hena ramay ▴ 10
@hena-ramay-6228
Last seen 5.5 years ago
Thank you very much Jason! This really helps me in doing what I want to do. I will contact you again if I have questions! Hena On Tue, Nov 5, 2013 at 6:59 PM, Jason Hackney <hackney.jason@gene.com>wrote: > Hi Hena, > > I am using the package ReportingTools and would like to know if is it > possible to publish t statistics in the report for differential expression > analysis using limma? > > > This depends quite a bit on what version of ReportingTools you are using. > For the current release version, there are a couple of ways to do this. The > most straightforward way is to write a custom function and override the > toReportDF method for MArrayLM objects. There is a helper function in the > package, ReportingTools:::.marrayLM.to.data.frame that might serve as a > template for getting the t-statistic. > > Here's kind of a rough sketch that I would use, drawn heavily from that > helper function, but missing some error checking: > > my.df.fn <- function (object, eSet = NULL, n = 1000, pvalueCutoff = 0.01, > lfc = 0, adjust.method = "BH", coef = NULL, make.plots = FALSE, > factor = NULL, ...) > { > dat <- topTable(object, number = n, p.value = pvalueCutoff, > lfc = lfc, coef = coef, adjust.method = adjust.method) > > selection <- rownames(dat) > > padj <- apply(object$p.value, 2, p.adjust, method = adjust.method) > padj <- padj[selection, coef] > > object <- object[selection, coef] > if (!missing(eSet) & !is.null(eSet)) { > eSet <- eSet[selection, ] > fdata <- ReportingTools:::annotate.genes(featureNames(eSet), > annotation(eSet), > keytype = "PROBEID", cols = list(ProbeId = "PROBEID", > EntrezId = "ENTREZID", Symbol = "SYMBOL", GeneName = > "GENENAME")) > } > > ret <- data.frame(fdata, Image = rep(NA, nrow(fdata)), > object$t, padj, stringsAsFactors = FALSE) > t.cols <- (ncol(fdata) + 2):(ncol(fdata) + 1 + ncol(object$t)) > colnames(ret)[t.cols] <- paste(colnames(object), "t-Statistic") > > pv.cols <- (ncol(fdata) + ncol(object$coef) + 2):ncol(ret) > colnames(ret)[pv.cols] <- paste(colnames(object), > "Adjusted p-Value") > return(ret) > } > > Once you have your function for coercing an MArrayLM object to a > data.frame, then you can pass it to the publish call in the .toDF argument: > > publish(my.fit, my.report, my.eset, n = 100, coef = 2, factor = > my.eset$groups, > .toDF = my.df.fn) > > The rest should work as expected. Let me know if that helps, or if you > have any further problems. > > Cheers, > > Jason > > > Thanks! > > > > Hena Ramay, PhD > Bioinformatician > Swiss Institute of Bioinformatics > Lausanne, Switzerland > > > > -- > Jason A. Hackney, Ph.D. > Bioinformatics and Computational Biology > Genentech > hackney.jason@gene.com > 650-467-5084 > > [[alternative HTML version deleted]]
ADD COMMENT

Login before adding your answer.

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