knitr::opts_chunk$set(
  collapse = TRUE,
  echo = FALSE,
  comment = "##",
  results = TRUE,
  warning = FALSE,
  message = FALSE,
  highlight = TRUE,
  background = 'grey',
  fig.cap = TRUE,
  out.height = "\\textheight",
  out.width = "\\textwidth"
)
#knitr::opts_chunk$set(out.height = "\\textheight",  ,
#                      out.extra = "keepaspectratio=false")
library(connector)
library(parallel)
detectCores(logical = FALSE) -> nworkers
nworkers <- nworkers - 1 # just for my laptop to survive 

p = params$infoReport$p
G = params$infoReport$G
data.selected = params$infoReport$data
f.selected = params$infoReport$feature
clusterdata = params$infoReport$clusterdata

Recap

The following parameters value has been selected:

  1. the number of basis spline, r if(!is.null(p)){paste("p = ",p) }else{ paste("p was not selected ")} ;
  2. the number of clusters, r if(!is.null(params$infoReport$G)){paste("G = ",params$infoReport$G) }else{ paste("G was not selected ")} .

Data overview

Number of curves: r length(unique(data.selected$$Dataset$ID ))

Overview number of points for each curve: r summary(as.vector(table(data.selected$Dataset$ID)))

Data visualisation

GrowPlot<-GrowthCurve(data.selected,
                      feature = f.selected)

GrowPlot$GrowthCurve_plot
Timegrid <- TimeGridDensity(data = data.selected)
Timegrid$TimeGrid_plot
if(!is.null(params$infoReport$truncTime) ){
  data.selected <- DataTruncation(data = data.selected,
               truncTime = params$infoReport$truncTime,
               feature =  f.selected)
  print(data.selected$GrowthCurve_plot)
}

Paramenters selection

if(is.character(params$infoReport$CrossLL)){

  readInputRdsFile = function(input_rds){
    input = tryCatch(readRDS(input_rds), 
    error = function(c) stop("The input *rds is invalid. Please fix the pRange input file, it must be defined wuth the entire path.")
    )
  }
  readInputRdsFile(params$infoReport$CrossLL)

}else if(is.vector(params$infoReport$CrossLL)){

  CrossLogLike<-BasisDimension.Choice(data.selected,
                                    p = params$infoReport$CrossLL,
                                    Cores = nworkers)
  CrossLogLike$CrossLogLikePlot
  CrossLogLike$KnotsPlot

}

The number of basis spline (p) is: r paste("p = ",p) .

if(!is.null(clusterdata)){
  IndexesPlot.Extrapolation(clusterdata)-> indexes

  print(indexes$Plot)

  knitr::kable(indexes$IndexesValues$fDB)
}

Cluster plots

if(!is.null(G) && !is.null(clusterdata) ) {
  ConsMatrix.Extrapolation(clusterdata,
                           data = data.selected)-> ConsInfo

  for( g in G){
    print("# Cluster ",g,"\n\n")

    print(ConsInfo[[paste0("G",g)]]$ConsensusPlot)

    clusterdata.selected <- MostProbableClustering.Extrapolation(stability.list = clusterdata,
                                                                 G = g)

    FMplots<- ClusterWithMeanCurve(clusterdata = clusterdata.selected,
                              data= data.selected,
                              feature = f.selected)

    print(FMplots$plotMeanCurve)
    #print(FMplots$plotsCluster$ALL)
  }

}


sysbioTurin/connector documentation built on April 9, 2024, 12:10 p.m.