_p_VinskaTrta/_I_EnViRoS/_S_01_Integ/_A_01_Desc-R/
% -*- TeX:Rnw:UTF-8 -*-
% ----------------------------------------------------------------
% .R knitr file ************************************************
% ----------------------------------------------------------------
%%
% \VignetteIndexEntry{}
% \VignetteDepends{}
% \VignettePackage{}
\documentclass[a4paper,12pt]{article}
%\usepackage[slovene]{babel}
\usepackage[utf8]{inputenc} %% must be here for Sweave encoding check
\input{abpkg}
\input{abcmd}
\input{abpage}
\usepackage{pgf,pgfarrows,pgfnodes,pgfautomata,pgfheaps,pgfshade}
\usepackage{amsmath,amssymb}
\usepackage{colortbl}
\input{mysweave}
<<include=FALSE, message=FALSE, warnings=FALSE, cache=FALSE>>=
require(knitr)
render_sweave()
opts_knit$set( concordance=TRUE
, root.dir = getwd()
, unnamed.chunk.label = "ch"
, width = 60
)
opts_knit$get("root.dir")
@
<<additional arguments, include=FALSE, echo=FALSE, message=FALSE, warnings=FALSE>>=
addArgs <- NULL
addArgs <- c(.delta=1,.alpha1=0.05,.alpha2=0.10)
addArgs <- c(.alpha=0.05
# , .deltam = 2
, .min.slope = 1.5
, .max.slope = 0.5
, .diff.slope = 1
# , .maxfc = 1
, .diff01 = 1 # a= 1, 1.5, 2
# , .deltam2 = 1
# , .diff.slope5 = 2
)
addArgs <- c(
.years = 18
)
@
<<pISA projects root, include=FALSE>>=
(.pISAloc <- gsub("/_p_.*","",getwd()))
@
<<eval=FALSE,include=FALSE>>=
require(knitr)
if(interactive()) knit(file.path(.pISAloc,"pISA-initialize.Rnw"))
@
<<pISA initialize, results='hide', include=FALSE, child=file.path(.pISAloc,"pISA-initialize.Rnw")>>=
@
<<my-utility-functions,results='hide',include=FALSE>>=
my.summary <-
function(x,...){
dims <- dimnames(x)
x <- as.data.frame((lapply(x, factor)))
dimnames(x) <- dims
summary(x)
}
#my.summary(phdata)
#
if(!exists("addObject")) {
addObject <- function(name=NULL,desc="",x=my.objects){
if(is.null(name)) x <- data.frame(name="",description="",class="", lenght=NA,ncol=NA) else {
nc <- ncol(name)
if(is.null(nc)) nc <- NA
x <- rbind(x,c(deparse(substitute(name)), desc, class(name), length(name), nc))
x <- x[x$name!="",]
}
rownames(x) <- x[,1]
return(x)
}
}
if(FALSE){
(my.objects <- addObject())
(my.objects <- addObject(t18,"Transcripts for 2018"))
}
@
<<set specific arguments,results='hide',include=FALSE,message=FALSE,warning=FALSE,echo=FALSE>>=
# Argumenti
# 1. Ime izvorne datoteke za analizo
# 2. Izbira genov (ime stolpca v featuredata)
#
.callName <- args[1]
for(i in 1:length(addArgs) ) {
assign(names(addArgs)[i],addArgs[i])
if( interactive() ) cat(names(addArgs[i])," ",get(names(addArgs[i])),"\n")
}
#getwd()
#args
@
\setkeys{Gin}{width=0.8\textwidth} % set graphicx parameter
\usepackage{lmodern}
\input{abfont}
% ----------------------------------------------------------------
\begin{document}
%% Sweave settings for includegraphics default plot size (Sweave default is 0.8)
%% notice this must be after begin{document}
%%% \setkeys{Gin}{width=0.9\textwidth}
% ----------------------------------------------------------------
\title{Analysis of transcriptomics and metabolomics data\\[4cm]
% \Sexpr{paste(names(addArgs),addArgs,collapse=" ",sep="=")}
}
\author{A. Blejec}
%\address{}%
%\email{}%
%
%\thanks{}%
%\subjclass{}%
%\keywords{}%
%\date{}%
%\dedicatory{}%
%\commby{}%
\thispagestyle{empty}
\maketitle
\vfill\hspace{5cm}\parbox{5cm}{
Parameters:\\[20pt]
\Sexpr{paste(names(addArgs),addArgs,collapse="\\\\",sep=" = ")}
}
% ----------------------------------------------------------------
%\begin{abstract}
%
%\end{abstract}
% ----------------------------------------------------------------
\clearpage
\tableofcontents
\clearpage
\listoftables
\clearpage
\listoffigures
<<Author:,echo=FALSE>>=
###############################################
## ##
## (c) Andrej Blejec (andrej.blejec@nib.si) ##
## ##
###############################################
@
<<initialize,echo=FALSE,include=FALSE,message=FALSE,warning=FALSE>>=
options(width=60)
library(Hmisc)
library(amisc)
library(Biobase)
#library(xlsReadWrite)
library(xtable)
#library(MASS)
library(lattice)
library(reshape2)
library(mixOmics)
@
\clearpage
\section{Task}
Analysis of transcriptomics and metabolomics data with canonical correlation.
Main ideas are from package \pkg{mixOmics}.
Final document in folder \file{/reports}:
<<>>=
fileName(outputFile)
@
\clearpage
\section{Information from pISA}
Data directory
<<>>=
.inroot
@
Results directory
<<>>=
.oroot
@
<<echo=FALSE>>=
catln("project:\t", .pName)
catln("Investigation: ",.iName)
catln("Study: ",.sName)
catln("Assay: ",.aName)
@
\clearpage
<<echo=FALSE, include=FALSE>>=
.testing <- TRUE
tst <- function(x, force=FALSE, ...) {
if(.testing|force) {
cat("-->", deparse(substitute(x)),..., "\n")
print(x)
}
invisible(x)
}
coef <- 1:5
tst(coef)
.testing <- FALSE
tst(coef,TRUE,"Za poskus force=TRUE")
@
\clearpage
\section{Data}
Priporočljivo je najprej prebrati phenodata in feature-data, potem pa podatke.
To omogoča izbor spremenljivk in vzorcev takoj za tem, ko podatke preberemo.
%% <<eval=!TRUE,include=TRUE>>=
%% out <- "From: 10a-ReadData.Rnw\n"
%% out <- paste(out,knit_child(file.path(".","10a-ReadData.Rnw"),quiet=TRUE))
%% @
%
%\Sexpr{out}
<<results='asis'>>=
cat(knit_child(file.path("../doc","10a_Read-Data.Rnw"),quiet=TRUE))
@
List of data objects:
<<>>=
my.objects
@
List of interesting genes, based on typification on 50* reports (key: \file{Transcript stats}.
Typification is extracted from the file in the relevant \code{output} directory.
To allow manual curation, the info is extracted from the \code{Type}
column.
<<>>=
tsfn <- getMeta(.adesc,"Transcript stats")
stat4 <- read.table(file.path(.aroot, tsfn), sep="\t", header=TRUE)
colnames(stat4)
rownames(stat4) <- stat4[,1]
head(stat4)
@
Select interesting genes
<<>>=
filter <- unlist(intgenes) #stat4$Type!=""
length(filter)
statig <- stat4[filter,]
dim(statig)
@
<<>>=
(my.objects <- addObject(stat4,"Statistics from transcript analysis (50*)"))
(my.objects <- addObject(statig,"Statistics for interesting genes"))
@
How many interesting genes are in the interesting bins?
<<>>=
filter <- rownames(statig) %in% unlist(intgenes)
sum(filter)
rownames(statig)[filter]
@
<<>>=
head(statig[filter, c("Type","BINCODE","DESCRIPTION")])
@
\clearpage
\subsection{Data overview}
<<>>=
x <- my.objects
x$name[1]
for(i in 1:nrow(x)){
cat("\n\n--------- ", x[i,1],": ",x[i,2], " -------------------------------\n\n",sep="")
print(x[i,])
cat("\n")
print(head(eval(as.name(x[i,1]))))
}
@
Factor for days within the year
<<>>=
pdata1819$day <- factor(as.character(pdata1819$day))
@
\clearpage
\section{Preparation of data for mixOmics}
Data for \pkg{mixOmics} analysis should follow the traditional mathematical orientation:
samples in rows, variables in columns. The matrices must have appropriate dimensions.
Due to different ranges and variability in years 2018 and 2019, we will analyze them separately.
\subsubsection{Selection of samples, transcripts and metaboloms}
Common samples in the given year (\Sexpr{.years}).
<<>>=
table(pdata1819$year)
select_year <- pdata1819$year %in% .years
sum(select_year)
@
<<50a_limma-fit-swp.Rnw, results='asis'>>=
cat(knit_child(file.path("../doc/","50a_limma-fit-swp.Rnw"),quiet=TRUE))
@
<<>>=
@
<<>>=
@
%% knitr child handling
%%
%<<child='child_file.Rnw'>>=
%@
%<<result="hide">>=
%out <- ""
%for ( linija in levels(phenodata$Celicna.linija))
%out <- paste(out,knit_child("child_file.rnw",quiet=TRUE))
%@
%\Sexpr{out}
%%
% ----------------------------------------------------------------
%\bibliographystyle{chicago}
%\addcontentsline{toc}{section}{\refname}
%\bibliography{ab-general}
%--------------------------------------------------------------
\clearpage
\appendix
\phantomsection\addcontentsline{toc}{section}{\appendixname}
%\section{\R\ funkcije}
%\input{}
\section{Metadata files}
\subsection{Project metadata}
<<echo=FALSE,results='asis'>>=
latex(.pdesc
, file = ""
, where = "!htbp"
, col.just = c("p{2.5in}", "p{3in}")
, collabel.just = rep("l",2)
, colnamesTexCmd = "ttfamily"
, rowname = NULL
, caption = "Project metadata"
, label = "tbl:pdesc"
, cellTexCmds = matrix("ttfamily",nrow(.pdesc),ncol(.pdesc))
)
@
\afterpage{\clearpage
\subsection{Investigation metadata}
<<echo=FALSE,results='asis'>>=
latex(.idesc
, file = ""
, where = "!htbp"
, col.just = c("p{2.5in}", "p{3in}")
, collabel.just = rep("l",2)
, colnamesTexCmd = "ttfamily"
, rowname = NULL
, caption = "Investigation metadata"
, label = "tbl:idesc"
, cellTexCmds = matrix("ttfamily",nrow(.idesc),ncol(.idesc))
)
@
}
{\clearpage
\subsection{Study metadata}
<<echo=FALSE,results='asis'>>=
latex(.sdesc
, file = ""
, where = "!htbp"
, col.just = c("p{2.5in}", "p{3in}")
, collabel.just = rep("l",2)
, colnamesTexCmd = "ttfamily"
, rowname = NULL
, caption = "Study metadata"
, label = "tbl:sdesc"
, cellTexCmds = matrix("ttfamily",nrow(.sdesc),ncol(.sdesc))
)
@
}
{\clearpage
\subsection{Assay metadata}
<<echo=FALSE,results='asis'>>=
latex(.adesc
, file = ""
, where = "!htbp"
, col.just = c("p{2.5in}", "p{3in}")
, collabel.just = rep("l",2)
, colnamesTexCmd = "ttfamily"
, rowname = NULL
, caption = "Assay metadata"
, label = "tbl:adesc"
, cellTexCmds = matrix("ttfamily",nrow(.adesc),ncol(.adesc))
)
@
}
\clearpage
\thispagestyle{empty}
\section{SessionInfo}
{\tiny
<<sessionInfo,results='asis',echo=FALSE>>=
cat("{\\ttfamily\n")
cat(win.version(),"\n")
toLatex(sessionInfo())
cat("{\n")
@
}
<<results='asis',echo=FALSE>>=
sdir <- gsub("/","/\\\\\\\\\n ",dirname(getwd()))
#cat("Project path:\n\\verb'",sdir,"'\\\\\n")
args <- commandArgs(trailingOnly = TRUE)
mainFile <- basename(args[1])
#
mainFilePath <- file.path("../doc", mainFile)
mainFilePath <- gsub("/./","/",mainFilePath)
projectName <- rev((strsplit(dirname(getwd()), "/"))[[1]])[1]
#
@
<<results='asis',echo=FALSE>>=
sdir <- dirname(getwd())
sdir <- strsplit(sdir,split="/")[[1]]
cdir <- sapply(1:length(sdir),function(x) paste(sdir[1:x],collapse="/"))
odir <- sdir
omike <- as.logical(grep("OMIKE",dirname(getwd())))
if(omike) {
odir[1] <- "O:"
.files <- paste("../doc",list.files("../doc","^.*\\.R"),sep="/")
.files <- file.copy(.files, file.path(.aroot,"scripts"))
}
ldir <- sapply(1:length(odir),function(x) paste(odir[1:x],collapse="/"))
#mc <- max(sapply(sdir,nchar))
#sdir <- sdir <- substr(paste0(sdir,"/ #"),1,mc+3)
#odir <- odir <- substr(paste0(odir,"/ #"),1,mc+3)
#
cat("\\normalsize Analysis project path: [\\href{run:",
dirname(getwd()),
"}{link}]\\\\\n",sep="")
cat("\\texttt{")
cat("\\begin{tabbing}\n")
cat("....\\=...............................\\=................................\\kill\n")
cat("\\>Local \\>Network\\\\")
for(i in 1:length(sdir)) {
cat("\\>\\href{run:",cdir[i],"}{",sdir[i],"} \\> ",sep="")
if(omike) cat("\\href{run:",ldir[i],"}{",odir[i],"}",sep="")
cat("\\\\\n")
}
cat(" \\> \n")
cat("\\end{tabbing}\n")
cat("} ")
@
<<results='asis',echo=FALSE>>=
cat("Main file : \\href{run:", mainFilePath, "}{", mainFilePath ,"}\n\n", sep="")
mainFile <- strsplit(mainFile,'.',fixed=TRUE)[[1]][1]
cat("Main file : \\href{run:../scripts/", mainFile, ".Rnw}
{../scripts/", mainFile ,".Rnw}\n\n", sep="")
projectName <- rev((strsplit(dirname(getwd()), "/"))[[1]])[1]
cat("Project file: [\\href{run:",
file.path(dirname(getwd()),paste0(projectName,".prj")),
"}{link}]\n",sep="")
#
@
\subsection*{View as vignette}
{\footnotesize
Source files can be viewed by pasting this code to \R\ console:\\}
\tiny{
%\begin{Schunk}
%\begin{Sinput}
\begin{verbatim}
<<projectFiles,echo=FALSE,results='asis'>>=
cat(' projectName <-"',projectName,'"\n',sep="")
cat(' mainFile <-"',mainFile,'"',sep="")
#
@
<<vignette,echo=FALSE,results='asis'>>=
cat(
' commandArgs()\n',
'library(tkWidgets)\n',
'openPDF(file.path(dirname(getwd()),"doc",\n',
'paste(mainFile,"PDF",sep=".")))\n',
'viewVignette("viewVignette", projectName,\n',
'file.path("../doc",paste(mainFile,"Rnw",sep=".")))\n'
)
#
@
\end{verbatim}
%\end{Sinput}
%\end{Schunk}
}
\vfill \hrule \vspace{3pt} \footnotesize{
%Revision \SVNId\hfill (c) A. Blejec%\input{../_COPYRIGHT.}
%\SVNRevision ~/~ \SVNDate
\noindent
\texttt{Git Revision: \gitCommitterUnixDate \gitAbbrevHash{} (\gitCommitterDate)} \hfill \copyright~A. Blejec\\
\texttt{ \gitReferences} \hfill \verb'\Sexpr{mainFilePath}'\\
}
<<eval=FALSE,echo=FALSE>>=
# getrootpath <- function() {
# fp <- (strsplit(getwd(), "/"))[[1]]
# file <- file.path(paste(fp[-length(fp)], collapse = "/"))
# return(file)
# }
# fileName <- function(name="bla",ext="PDF") paste(name,ext,sep=".")
@
\end{document}
% ----------------------------------------------------------------
Creators and SubmitterCreator
Submitter
Activity
Views: 914 Downloads: 50
Created: 7th Nov 2021 at 15:25
Last updated: 7th Nov 2021 at 15:25
AttributionsNone
Version History
Version 1 (earliest) Created 7th Nov 2021 at 15:25 by Andrej Blejec
No revision comments
Download
View content
https://orcid.org/0000-0001-7484-6031