#Load miodin library(miodin) #Create project mp <- MiodinProject(name = "VerticalIntegration") #Study design library(data.table) pheno <- fread(system.file("extdata/tcgaPheno.txt", package = "miodindata")) #Read pheno data from miodindata package sampleTable <- data.frame( SampleName = pheno$patientID, #Sample names SamplingPoint = rep("sp1", nrow(pheno)), #One sampling point (must be specified) VitalStatus = ifelse(pheno$vital_status == 1, "Alive", "Diseased") #Whether samples are alive or diseased ) assayTableRNA <- data.frame( SampleName = pheno$patientID, #Sample names DataFile = rep(system.file("extdata/tcgaRNA.txt", #Data file containing mRNA expression package = "miodindata"), nrow(pheno)), DataColumn = pheno$patientID #Column in data file corresponding to each sample ) assayTableMiRNA <- data.frame( SampleName = pheno$patientID, #Sample names DataFile = rep(system.file("extdata/tcgaMiRNA.txt", #Data file containing miRNA expression package = "miodindata"), nrow(pheno)), DataColumn = pheno$patientID #Column in data file corresponding to each sample ) assayTableMethyl <- data.frame( SampleName = pheno$patientID, #Sample names DataFile = rep(system.file("extdata/tcgaMethyl.txt", #Data file containing methylation values package = "miodindata"), nrow(pheno)), DataColumn = pheno$patientID #Column in data file corresponding to each sample ) ms <- studyDesignCaseControl( #Create a miodin stiudy (case-control design) studyName = "TCGAStudy", #Name of study in project (must be unique) factorName = "VitalStatus", #Column in sample table containing vital status of patients caseName = "Diseased", #Factor level corresponding to cases controlName = "Alive", #Factor level corresponding to controls contrastName = "VitalStatus", #Name of contrast representing the comparison between cases and controls numCase = 287, #Number of cases numControl = 51, #Number of controls sampleTable = sampleTable, #Sample table data frame assayTable = assayTableRNA, #Assay table data frame (mRNA) assayTableName = "RNAseq") + #Assay table name (mRNA) studyAssayTable("miRNAseq", assayTableMiRNA) + #Adding another assay table (miRNA) studyAssayTable("Methyl", assayTableMethyl) #Adding another assay table (methylation) insert(ms, mp) #Insert study into project rm(pheno, sampleTable, assayTableRNA, assayTableMiRNA, assayTableMethyl, ms) #Import and process mw <- MiodinWorkflow("TCGAFlow") #Create a new workflow mw <- mw + importProcessedData( #Module to import processed (counts) RNA-seq data name = "RNA importer", #Name of module in workflow (must be unique) experiment = "sequencing", #Type of experimental platform (microarray, sequencing or mass spec) dataType = "rna", #Omics data type (rna, snp, mutation or methylation or protein) studyName = "TCGAStudy", #Name of study in project assayName = "RNAseq", #Name of assay table in study datasetName = "TCGAData", #Name of output dataset contrastName = "VitalStatus" #Name of contrast to consider for coloring samples in QC plots ) %>% processSequencingData( #Module to process imported RNA-seq data name = "RNA processor", #Name of module in workflow contrastName = "VitalStatus", #Name of contrast (determines which samples to process) filterLowCount = TRUE, #Filter genes with low counts stabilizeVariance = TRUE, #Perform variance stabilization stabilizeVarianceMethod = "vst" #Normalization method for variance stabilization ) + importProcessedData( #Import miRNA-seq count data name = "miRNA importer", experiment = "sequencing", dataType = "rna", studyName = "TCGAStudy", assayName = "miRNAseq", datasetName = "TCGAData", contrastName = "VitalStatus" ) %>% processSequencingData( #Process imported miRNA-seq data name = "miRNA processor", contrastName = "VitalStatus", filterLowCount = TRUE, stabilizeVariance = TRUE, stabilizeVarianceMethod = "vst" ) + importProcessedData( #Import methylation data name = "Methyl importer", experiment = "microarray", dataType = "methylation", studyName = "TCGAStudy", assayName = "Methyl", datasetName = "TCGAData", contrastName = "VitalStatus", chipName = "HumanMethylation450K" #Name of microarray used to measure methylation ) %>% processMicroarrayData( #Process imported methylation data name = "Methyl processor", contrastName = "VitalStatus", filterSNPandCH = TRUE, #Filter out bad probes (according to DMRcate package) filterNonCG = TRUE #Filter out non-CG probes ) mw <- insert(mw, mp) #Insert workflow into project mw <- execute(mw) #Execute workflow #Integrate and analyze mw <- mw + integrateAssays( #Module to integrate data into single dataset name = "Assay integrator", #Name of module upstreamModules = c("RNA processor", #Upstream modules from which data should be integrated "miRNA processor", "Methyl processor"), datasetName = "TCGAData" #Name of output dataset ) %>% performFactorAnalysis( #Module for performing factor analysis name = "Factor analyzer", #Name of module analysisMethod = "mofa", #Analysis method (mofa or bsplsda) annotColor = "VitalStatus", #Contrast to use for coloring samples in plots numFactors = 2, #Number of latent factors in the model seed = 123 #Set seed to render results reproducible ) mw <- execute(mw) #Export results export(mp, "dataset", "TCGAData") #Export TCGAData dataset to disk export(mp, "analysisResult", "TCGAData") #Export analysis result to disk saveDataFile(mp) #Save project and objects in hierarchy