The analysis below can be reproduced by one of the following methods:

  1. Running the commands in R.
  2. Running discoBatch() with the parameters in section \@ref(parameter-settings).
  3. Interactively with discoApp() with the parameters in \@ref(parameter-settings).

Note: This report is static and does not perform any reactive data processing.

To run commands directly in R, import the data and input parameters:

# Choose an appropriate command for importing the data
# indata <- read.csv("path/to/input_data.csv") # From CSV file
# indata <- readRDS("path/to/input_data.RDS") # From R data file
# indata <- DiscoRhythm::discoGetSimu() # Import example dataset

# Read input parameters and put them into the global environment
# discorhythm_inputs <- readRDS('discorhythm_inputs.RDS')
# list2env(discorhythm_inputs,envir=.GlobalEnv)

Data Processing

Parameter Settings

Below is a table of all parameters input to this report. See ?discoBatch R documentation for parameter descriptions.

knitr::kable(data.frame(
  "Parameter"=c("cor_threshold","cor_method","cor_threshType","pca_threshold",
                "pca_scale","pca_pcToCut","aov_method","aov_pcut","aov_Fcut",
                "avg_method","osc_method","timeType","main_per",
                "osc_period"),
  "Value"=c(cor_threshold,cor_method,cor_threshType,pca_threshold,
            pca_scale,paste(pca_pcToCut,collapse = " "),
            aov_method,aov_pcut,aov_Fcut,avg_method,
            paste(osc_method,collapse=" "),
            timeType,main_per,osc_period)
  ), format = "markdown")

Main Computations

batchscript=system.file("", "DiscoRhythm_batch.R",
                               package = "DiscoRhythm",
                               mustWork = TRUE)

Below is all R code necessary to generate the main DiscoRhythm results. These results will be used in section \@ref(visualizations) for generating the summary figures. Refer to the "Introduction to DiscoRhythm" document for a detailed description of the workflow steps.

# local=TRUE to run within the environment used to call this Rmd
source(batchscript, local = TRUE)

Visualizations

Importing the DiscoRhythm plotting functions used by the web application for use in this report. To reproduce these results, ensure you have all necessary package versions (See \@ref(session-info)). Refer to the r BiocStyle::Biocpkg('DiscoRhythm') user's guide or web application for details on each figure.

source(system.file("app/code/server", "plots.R", package = "DiscoRhythm",
                   mustWork = TRUE))

Process Input Data

Design Summary

knitr::kable(discoDesignSummary(SummarizedExperiment::colData(selectDataSE)), format = "markdown")

Outlier Detection

Inter-sample Correlations {.tabset}

Average Correlations

plotly::ggplotly(plotAvgCor(SummarizedExperiment::colData(selectDataSE),CorRes$meanCor,
                            corCut = CorRes$threshold,tUnit = "hr"))

Correlation Heatmap

plotHeatMCor(CorRes$corMat,1)

PCA {.tabset}

PC Score Distributions

plotly::ggplotly(
  plotPCAdists(PCAres,SDfactor = pca_threshold,pcToUse = pca_pcToCut)
)

One Pair

gridExtra::grid.arrange(
  plotPCAWithShape(PCAres$x,as.data.frame(SummarizedExperiment::colData(selectDataSE)),
                   col = "None",1,2,
                   PCAres$outliers)+
    ggtitle("Before Outlier Removal"),
  plotPCAWithShape(PCAresAfter$x,as.data.frame(SummarizedExperiment::colData(selectDataSE)),
                   col = "None",1,2)+
    ggtitle("After Outlier Removal"),
  ncol=2)

Scree Plot

plotPCAstats(PCAres$table,PCAresAfter$table,pcToUse = pca_pcToCut)

All Pairs {.tabset}

Before Outlier Removal

plotPCAPairs(PCAres$x,c("PC1","PC2","PC3","PC4"))

After Outier Removal

invisible(plotPCAPairsAfter(PCAresAfter$x,c("PC1","PC2","PC3","PC4"),
                            PCAres$outliers))

Outlier Summary {.tabset}

Outliers

DT::datatable(as.data.frame(
  SummarizedExperiment::colData(selectDataSE)[PCAres$outliers | CorRes$outliers,]
))

Remaining Samples

knitr::kable(discoDesignSummary(SummarizedExperiment::colData(FilteredSE)), format = "markdown")

Replicate Analysis {.tabset}

ANOVA P-Value Histogram

if(aov_method!='None') plotPvalues(ANOVAres$aovP,50, aov_pcut, 'ANOVA')

Signal-to-noise

if(aov_method!='None') ObsVsExpSNR(ANOVAres$allStats,aov_Fcut)

Period Detection

Period Detection

plotPeriodDetect(PeriodRes)

PC Fits to Fixed Period {.tabset}

PC Cosinor Fits

plotOVpcaScatter(OVpca = OVpca,colData(FinalSE),osc_period,
                 PCsToUse = paste0("PC",1:4))

Cosinor Table

pcaSE <- discoDFtoSE(data.frame("PC"=1:ncol(OVpca$x),t(OVpca$x)),
                        colData(FinalSE))
knitr::kable(
  discoODAs(pcaSE,method="CS")$CS,
  format = "markdown"
)

Oscillation Detection

Detection Summary {.tabset}

P-value Histograms

plotPQValueHist(discoODAres,bg = seq_len(nrow(FinalSE)),50,
                cutoff = 0.05,discoODAid2name)

Acrophase Rose Diagrams

fg <- lapply(discoODAres,function(x) which(x$pvalue<0.05))
plotAllAcroHist(discoODAres,fg,50,osc_period,TRUE,discoODAid2name)

Amplitude Histogram

plotAmpliHist(discoODAres,bg = seq_len(nrow(FinalSE)),
              fg=fg[['CS']],50,'')

Intersection of Methods

allIntersect(fg)

Session Info

sessionInfo()


matthewcarlucci/DiscoRhythm documentation built on March 24, 2022, 10:22 a.m.