knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE )
resultsV2 <- params$resultsxx
parameterV2 <- params$parametersxx

Cluster profiling aims to group the proteins based on protein expression information. More biological conditions in your dataset lead to more informative clusterings.

if (nrow(resultsV2$prot$factors()) < 8){
    cat('<font color="red">WARNING: the number of samples in your dataset is less than 8, possibly because the number of conditions is low.\n Although the clustering algorithm will still produce clusters, these will arise because of random correlation among the proteins.</font>\n\n')
} else cat("")
if (resultsV2$nrCluster == 1 || resultsV2$dataDims["nrPortNoNas"] < 2000){
    cat('<font color="red">WARNING: be aware that the clustering algorithm can not explain all data variability, if the number of proteins is not enough to get statistically significant results.\n If the clustering results do not discriminate between the expected classes consider to increase the number of proteins if possible.</font>\n\n')
} else cat("")

Run Summary

Data QC

prot <- resultsV2$prot
pl <- prot$get_Plotter()
pl$intensity_distribution_density()
pNa <- pl$NA_heatmap()
p <- pl$heatmap()
pc <- pl$heatmap_cor()
print(pNa)
print(p)
pl$pca()

Cluster proteins

isclust <- if(resultsV2$nrCluster > 1) {TRUE} else {FALSE}
validScaledM <- if(nrow(resultsV2$scaledM) > 1) {TRUE} else {FALSE}
plot(resultsV2$dendrogram, leaflab = "none" )
scaledM <- resultsV2$scaledM

bb <- as_tibble(scaledM,rownames = "protein_Id")
bb <- bb %>% pivot_longer(-"protein_Id", names_to = "sampleName", values_to = "transformedIntensity")
toplot <- inner_join(resultsV2$clusterAssignment, bb)
neword <- labels(as.dendrogram(stats::hclust(dist(t(scaledM)))))
toplot$sampleName <- fct_relevel(toplot$sampleName, neword)
ggplot(toplot, aes(x = sampleName,y = transformedIntensity, group = protein_Id)) +
  geom_line(color = "lightgrey") + theme_bw() +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) +
  facet_wrap(~Cluster)

Over Representation Analysis (ORA)

GO Biological Process

figWIncrease <- 0.5
figHeightIncrease <- 0.2

P <- resultsV2$resGOEnrich$BP
figwidth <- 10
figheight <- 5
if (!is.null(P$clustProf)) {
  dt <- as.data.frame(P$clustProf)
  nrOra <- min(10, length(unique(dt$ID)))
  nrClust <- length(unique(dt$Cluster))
  figwidth <- max(figwidth, 6 + nrClust*figWIncrease)
  figheight <- max(figheight, 3 + nrClust*nrOra*figHeightIncrease)
}
print(c(figwidth,figheight))
isthere <- !is.null(P$clustProf)
clusterProfiler::dotplot(P$clustProf, title = P$mt, showCategory = nrOra)
DT::datatable(as.data.frame(P$clustProf),caption = mt)

GO Molecular Function

P <- resultsV2$resGOEnrich$MF
figwidth <- 10
figheight <- 5
if (!is.null(P$clustProf)) {
  dt <- as.data.frame(P$clustProf)
  nrOra <- min(10,length(unique(dt$ID)))
  nrClust <- length(unique(dt$Cluster))
  figwidth <- max(figwidth, 6 + nrClust*figWIncrease)
  figheight <- max(figheight, 3 +  nrClust*nrOra*figHeightIncrease)
}

isthere <- !is.null(P$clustProf)
print(nrOra)
dotplot(P$clustProf,title = P$mt, showCategory   = nrOra)
DT::datatable(as.data.frame(P$clustProf),caption = mt)

GO Cellular Component

P <- resultsV2$resGOEnrich$CC
figwidth <- 10
figheight <- 5
if (!is.null(P$clustProf)) {
  dt <- as.data.frame(P$clustProf)
  nrOra <- min(10,length(unique(dt$ID)))
  nrClust <- length(unique(dt$Cluster))
  figwidth <- max(figwidth, 6 + nrClust*figWIncrease)
  figheight <- max(figheight, 3 +  nrClust*nrOra*figHeightIncrease)
}

isthere <- !is.null(P$clustProf)
dotplot(P$clustProf,title = P$mt, showCategory = nrOra)
DT::datatable(as.data.frame(P$clustProf),caption = mt)


protViz/prora documentation built on Dec. 12, 2021, 12:32 a.m.