##################################################
## R script for MetaboAnalyst
## Description: report generation using Sweave
## Note: most analyses were already performed, only need to embedding
## the results to the right place without rerun the whole analysis
## through Sweave. Only some auxilliary info (i.e. time, version etc need to
## run R throught Sweave
##
## Author: Jeff Xia, jeff.xia@mcgill.ca
## McGill University, Canada
##
## License: GNU GPL (>= 2)
###################################################
CreatePDFReport<-function(usrName){
# create the Rnw file
file.create("Analysis_Report.Rnw");
# open for write
rnwFile <<- file("Analysis_Report.Rnw", "w")
# create a global counter to label figures
fig.count <<- 0;
table.count <<- 0;
if(analSet$type == "stat" ){
CreateStatRnwReport(usrName);
}else if(analSet$type == "ts"){
CreateTimeSeriesRnwReport(usrName);
}else if(substr(analSet$type, 0, 4) == "mset"){
CreateEnrichRnwReport(usrName);
}else{
CreatePathRnwReport(usrName);
}
# close opened files
close(rnwFile);
Sweave("Analysis_Report.Rnw");
tools::texi2dvi("Analysis_Report.tex", pdf = TRUE, quiet=TRUE);
}
################################
## MetaboAnalyst statistics
###############################
# write .Rnw file template
CreateStatRnwReport<-function(usrName){
CreateHeader(usrName);
CreateStatIntr();
CreateStatIOdoc();
CreateStatNORMdoc();
InitStatAnalMode();
if(exists("analSet")){
CreateUNIVdoc();
CreateANOVAdoc();
CreateCorrDoc();
CreatePCAdoc();
CreatePLSdoc();
CreateSAMdoc();
CreateEBAMdoc();
CreateHCdoc();
CreateKMdoc();
CreateSOMdoc();
CreateRFdoc();
CreateSVMdoc();
}else{
CreateAnalNullMsg();
}
CreateStatFooter();
}
# create header
CreateHeader<-function(usrName){
header <- c("\\documentclass[a4paper]{article}",
"\\usepackage[margin=1.0in]{geometry}",
"\\usepackage{longtable}",
"\\SweaveOpts{eps=FALSE,pdf=TRUE}",
"\\title{Metabolomic Data Analysis with MetaboAnalyst 3.0}",
paste("\\author{ User ID: ", usrName, " }", sep=""),
"\\begin{document}",
"\\parskip=.3cm",
"\\maketitle");
cat(header, file=rnwFile, sep="\n", append=TRUE);
}
CreateStatIntr<-function(){
descr <- c("\\section{Data Processing and Normalization}\n");
cat(descr, file=rnwFile, append=TRUE);
}
# read and process the raw data
CreateStatIOdoc<-function(){
descr <- c("\\subsection{Reading and Processing the Raw Data}\n",
"MetaboAnalyst accepts a variety of data types generated in metabolomic studies,",
"including compound concentration data, binned NMR/MS spectra data, NMR/MS peak",
"list data, as well as MS spectra (NetCDF, mzXML, mzDATA).",
"Users need to specify the data types when uploading their data in order for",
"MetaboAnalyst to select the correct algorithm to process them.\n",
paste("Table", table.count<<-table.count+1,"summarizes the result of the data processing steps.\n")
);
cat(descr, file=rnwFile, append=TRUE);
# error checking
if(is.null(dataSet$orig) | is.null(dataSet$proc) | is.null(dataSet$cls)){
errorMsg<- c(descr, "Error occured during reading the raw data ....",
"Failed to proceed. Please check if the data format you uploaded is correct.",
"For further information, please contact \\texttt{jeff.xia@mcgill.ca} with",
"a description of the problem. Your feedback is highly appreciated!\n");
cat(errorMsg, file=rnwFile, append=TRUE);
return();
}
if(dataSet$type=="conc"){
descr<-c("\\subsubsection{Reading Concentration Data}\n",
"The concentration data should be uploaded in comma separated values (.csv) format.",
"Samples can be in rows or columns, with class labels immediately following the sample IDs.\n");
cat(descr, file=rnwFile, append=TRUE);
cat("\n\n", file=rnwFile, append=TRUE);
cat(dataSet$read.msg, file=rnwFile, append=TRUE, sep="\n");
}else if(dataSet$type=="specbin"){
descr<-c("\\subsubsection{Reading Binned Spectral Data}\n",
"The binned spectra data should be uploaded in comma seperated values (.csv) format.",
"Samples can be in rows or columns, with class labels immediately following the sample IDs.\n");
cat(descr, file=rnwFile, append=TRUE);
cat("\n\n", file=rnwFile, append=TRUE);
cat(dataSet$read.msg, file=rnwFile, append=TRUE, sep="\n");
}else if(dataSet$type=="pktable"){
descr<-c("\\subsubsection{Reading Peak Intensity Table}\n",
"The peak intensity table should be uploaded in comma separated values (.csv) format.",
"Samples can be in rows or columns, with class labels immediately following the sample IDs.\n");
cat(descr, file=rnwFile, append=TRUE);
cat("\n\n", file=rnwFile, append=TRUE);
cat(dataSet$read.msg, file=rnwFile, append=TRUE, sep="\n");
}else if(dataSet$type=="nmrpeak"){
descr<-c("\\subsubsection{Reading NMR Peak List and Intensities Data}\n",
"NMR peak list and intensities data should be uploaded as one zip file. It contains subfolders, one for",
"each group. Each folder contains peak list files, one per spectrum. The peak list format",
"is a a two-column comma separated values - the first column indicates peak position (ppm)",
"and the second one for peak intensities. The first line is assumed to be column labels.",
"The files should be saved in .csv format. For paired analysis, users need to upload",
"a text file specifying the paired information. Each pair is indicated by their sample names",
"seperated by a colon \":\" with one pair per line.\n");
cat(descr, file=rnwFile, append=TRUE);
cat("\n\n", file=rnwFile, append=TRUE);
cat(dataSet$read.msg, file=rnwFile, append=TRUE, sep="\n");
descr<-c("\\subsubsection{Peak List Alignment}\n",
"Proximal peaks are first grouped together based on their position using a moving window of 0.03 ppm",
"and a step of 0.015 ppm. Peaks of the same group are aligned to their median positions across all samples.",
"If more than one peak from the same sample appear in the same group, they will be replaced by their sum.",
"Some peaks that are detected in very few samples (less than half in both classes) are excluded.",
"The aligned peaks are reorganized into a single data matrix for further analysis. The name of the parent",
"folder is used as class label for each sample.\n");
cat(descr, file=rnwFile, append=TRUE);
cat("\n\n", file=rnwFile, append=TRUE);
cat(dataSet$proc.msg, file=rnwFile, append=TRUE, sep="\n");
}else if(dataSet$type=="mspeak"){
descr<-c("\\subsubsection{Reading MS Peak List and Intensities Data}\n",
"MS peak list and intensities data should be uploaded as one zip file. It contains subfoulders with one for",
"each group. Each folder contains peak list files, one per spectrum. The MS peak list format",
"is either a two-column (mass and intensities) or three-column (mass, retention time, and intensities)",
"comma separated values. The first line is assumed to be column labels.",
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Metabo-master.zip (57个子文件)
Metabo-master
learn
svm.R 716B
Rmd
funset.Rmd 5KB
sem_with_r.Rmd 3KB
template.Rmd 5KB
opls_da.R 4KB
swirl.R 23B
MetaboAnalyst
website
sigfeatures.R 7KB
path_stats.R 9KB
asca.R 29KB
classification.R 13KB
KEGGUtils.R 13KB
lipomics.R 9KB
roc_utils.R 72KB
qc_utils.R 10KB
live_graphics.R 3KB
normalization.R 12KB
power_analysis.R 3KB
timecourse.R 24KB
twoway_anova.R 5KB
enrich_graphics.R 16KB
name_match.R 20KB
processing.R 24KB
batch_check.R 12KB
enrich_libutils.R 15KB
univartest.R 34KB
chemometrics.R 34KB
misceutils.R 58KB
AnotUtils.R 5KB
correlations.R 8KB
sweavereporter.R 119KB
datautils.R 20KB
clustering.R 15KB
enrich_stats.R 14KB
IntegMethods.R 13KB
path_graphics.R 11KB
main.R 836B
pls_use.R 932B
mvr.R 4KB
source_github.R 880B
pca.R 500B
osc_pls_da.R 2KB
oplsda.R 9KB
Evaluation of Orthogonal Signal Correction for PLS modeling (OSC-PLS and OPLS) _ R-bloggers_files
secureAnonymousFramework 161KB
RBloggers 1KB
plsda_use.R 3KB
zaqizaba
path_analysis_bootstrap.R 3KB
Untitled.R 312B
path_analysis_bootstrap2.R 3KB
path_analysis.R 2KB
nsfc.R 214B
xx.R 4KB
heatmap_similar.R 19B
bootstrap.R 3KB
path_analysis2.R 777B
drug_similar.R 2KB
shouyao
gene_info.R 147B
mysql.R 1KB
共 57 条
- 1
资源评论
学习资源网
- 粉丝: 938
- 资源: 1914
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功