Data loading

suppressPackageStartupMessages({
  library(SummarizedExperiment)
  library(SEtools)
  library(edgeR)
  library(DT)
  library(pheatmap)
  library(plotly)
  library(dplyr)
  library(sva)
  library(viper)
})
source("Functions/EDC_Functions.R")
source("Functions/CriFormatted.R")
load("Data/AllSEcorrected.RData",verbose=T)
## Loading objects:
##   SEs
##   DEAs
load("Data/regulon_weighted.RData", verbose = T)
## Loading objects:
##   regulon

psychencode network

Fetal chronic

se <- SEs$chronic.fetal
se <- SEtools::log2FC(se, "corrected", controls=se$EXPO=="CNT", isLog = TRUE)
ag <- readRDS("Data/psychencode_reduced.rds")
ag <- ag[which(ag[,1] %in% row.names(se) & ag[,2] %in% row.names(se)),]
write.table( ag, file="Data/psychencode_reduced.txt", col.names=F, row.names=F, sep="\t", quote=F)
tf1.ch <- TFA(se, DEAs$chronic.fetal, ~EXPO, "Data/psychencode_reduced.txt",
              testCoef=c("EXPO1X","EXPO1000X"), assayName="corrected")
## WARNING! NOT CONVERGENT! 
## number of iterations= 1000 
## WARNING! NOT CONVERGENT! 
## number of iterations= 1000 
## WARNING! NOT CONVERGENT! 
## number of iterations= 1000
tf1.ch <- SEtools::log2FC(tf1.ch, "viper", tf1.ch$EXPO=="CNT", isLog=TRUE)
plotTFA(tf1.ch)
## Warning: `line.width` does not currently support multiple values.

We restrict ourselves to transcription factors whose expression pattern is coherent with their differential activity:

rd <- rowData(tf1.ch)
sig <- row.names(rd)[(sign(rd$activity.max.logFC)==sign(rd$expression.logFC) & rd$activity.FDR<0.05 & rd$expression.FDR<0.1)]
sef <- se
m <- mergeSEs(list(expression=se,activity=tf1.ch), do.scale = FALSE)
m$assay <- m$Dataset
sehm(m[,which(m$EXPO %in% c("CNT","1X","1000X"))], sig, do.scale = FALSE, assayName = "log2FC", anno_columns = c("EXPO2","assay"), breaks = 0.99, main="Expression and activity of significant TFs")

FetTF <- sig

Organoids chronic

se <- SEs$chronic.org
se <- SEtools::log2FC(se, "corrected", controls=se$EXPO=="CNT", isLog = TRUE)
ag <- readRDS("Data/psychencode_reduced.rds")
ag <- ag[which(ag[,1] %in% row.names(se) & ag[,2] %in% row.names(se)),]
write.table( ag, file="Data/psychencode_reduced.txt", col.names=F, row.names=F, sep="\t", quote=F)
to1.ch <- TFA(se, DEAs$chronic.org, ~EXPO, "Data/psychencode_reduced.txt",
              testCoef=c("EXPO1X","EXPO1000X"), assayName="corrected")
## WARNING! NOT CONVERGENT! 
## number of iterations= 1000 
## WARNING! NOT CONVERGENT! 
## number of iterations= 1000 
## number of iterations= 338
to1.ch <- SEtools::log2FC(to1.ch, "viper", to1.ch$EXPO=="CNT", isLog=TRUE)
plotTFA(to1.ch)
## Warning: `line.width` does not currently support multiple values.

We restrict ourselves to transcription factors whose expression pattern is coherent with their differential activity:

rd <- rowData(to1.ch)
sig <- row.names(rd)[(sign(rd$activity.max.logFC)==sign(rd$expression.logFC) & rd$activity.FDR<0.05 & rd$expression.FDR<0.05)]
m <- mergeSEs(list(expression=se,activity=to1.ch), do.scale = FALSE)
m$assay <- m$Dataset
sehm(m[,which(m$EXPO %in% c("CNT","1X","1000X"))], sig, do.scale = FALSE, assayName = "log2FC", anno_columns = c("EXPO2","assay"), breaks = 0.99, main="Expression and activity of significant TFs",show_rownames = T)

OrgTF <-sig
TF <- union(OrgTF,FetTF) 

Merge

rd <- merge(rowData(to1.ch), rowData(tf1.ch), by="row.names", suffixes=c("organoid","fetal"))
sig <- rd$Row.names[which(
  apply(sign(as.matrix(rd[,grep("logFC",colnames(rd))])),1,FUN=function(x) length(unique(x))==1) &
  rd$activity.FDRorganoid < 0.1 & rd$activity.FDRfetal < 0.2 &
    rd$expression.FDRorganoid < 0.25 & rd$expression.FDRfetal < 0.25
)]
m <- mergeSEs(list(exp.org=se,activity.org=to1.ch,exp.fetal=sef, activity.fetal=tf1.ch), do.scale = FALSE)
m$assay <- c("expression","activity")[1+as.numeric(grepl("activity",m$Dataset))]
m$system <- c("fetal","organoid")[1+as.numeric(grepl("org",m$Dataset))]
sehm(m[,which(m$EXPO %in% c("CNT","1X","1000X"))], sig, do.scale = FALSE, assayName = "log2FC", anno_columns = c("EXPO2","assay","system"), breaks = 0.99, main="Expression and activity of significant TFs in both fetal and organoids", sortRowsOn = NULL)

TFshort<-sig
save(OrgTF,FetTF,TF, TFshort, file = "Data/HormonalGenes/HormonalTFs/TF.RData")
Org <- to1.ch
Fet <- tf1.ch
save(Org, Fet, file="Data/TFA.RData")

Authors

Nicolò Caporale: ,

Cristina Cheroni:

Pierre-Luc Germain:

Giuseppe Testa:

Lab: http://www.testalab.eu/

‘Date: December 01, 2021’

sessionInfo()
## R version 4.0.3 (2020-10-10)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Big Sur 10.16
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] parallel  stats4    stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
##  [1] viper_1.24.0                sva_3.38.0                 
##  [3] BiocParallel_1.24.1         genefilter_1.72.1          
##  [5] mgcv_1.8-34                 nlme_3.1-152               
##  [7] dplyr_1.0.5                 plotly_4.9.3               
##  [9] ggplot2_3.3.3               pheatmap_1.0.12            
## [11] DT_0.17                     edgeR_3.32.1               
## [13] limma_3.46.0                SEtools_1.4.0              
## [15] SummarizedExperiment_1.20.0 Biobase_2.50.0             
## [17] GenomicRanges_1.42.0        GenomeInfoDb_1.26.2        
## [19] IRanges_2.24.1              S4Vectors_0.28.1           
## [21] BiocGenerics_0.36.0         MatrixGenerics_1.2.1       
## [23] matrixStats_0.58.0         
## 
## loaded via a namespace (and not attached):
##   [1] Rtsne_0.15             colorspace_2.0-0       rjson_0.2.20          
##   [4] class_7.3-18           ellipsis_0.3.1         circlize_0.4.12       
##   [7] XVector_0.30.0         GlobalOptions_0.1.2    clue_0.3-58           
##  [10] farver_2.1.0           bit64_4.0.5            AnnotationDbi_1.52.0  
##  [13] fansi_0.4.2            codetools_0.2-18       splines_4.0.3         
##  [16] cachem_1.0.4           knitr_1.31             jsonlite_1.7.2        
##  [19] Cairo_1.5-12.2         annotate_1.68.0        kernlab_0.9-29        
##  [22] cluster_2.1.1          png_0.1-7              compiler_4.0.3        
##  [25] httr_1.4.2             assertthat_0.2.1       Matrix_1.3-2          
##  [28] fastmap_1.1.0          lazyeval_0.2.2         htmltools_0.5.1.1     
##  [31] tools_4.0.3            gtable_0.3.0           glue_1.4.2            
##  [34] GenomeInfoDbData_1.2.4 V8_3.4.0               Rcpp_1.0.6            
##  [37] jquerylib_0.1.3        vctrs_0.3.7            crosstalk_1.1.1       
##  [40] iterators_1.0.13       xfun_0.21              stringr_1.4.0         
##  [43] openxlsx_4.2.3         lifecycle_1.0.0        XML_3.99-0.5          
##  [46] MASS_7.3-53.1          zlibbioc_1.36.0        scales_1.1.1          
##  [49] TSP_1.1-10             RColorBrewer_1.1-2     ComplexHeatmap_2.6.2  
##  [52] yaml_2.2.1             curl_4.3               memoise_2.0.0         
##  [55] sass_0.3.1             segmented_1.3-2        stringi_1.5.3         
##  [58] RSQLite_2.2.3          highr_0.8              randomcoloR_1.1.0.1   
##  [61] foreach_1.5.1          e1071_1.7-4            seriation_1.2-9       
##  [64] zip_2.1.1              shape_1.4.5            rlang_0.4.10          
##  [67] pkgconfig_2.0.3        bitops_1.0-6           evaluate_0.14         
##  [70] lattice_0.20-41        purrr_0.3.4            htmlwidgets_1.5.3     
##  [73] bit_4.0.4              tidyselect_1.1.0       magrittr_2.0.1        
##  [76] R6_2.5.0               generics_0.1.0         DelayedArray_0.16.1   
##  [79] DBI_1.1.1              pillar_1.5.1           withr_2.4.1           
##  [82] mixtools_1.2.0         survival_3.2-7         RCurl_1.98-1.2        
##  [85] tibble_3.1.0           crayon_1.4.1           KernSmooth_2.23-18    
##  [88] utf8_1.2.1             rmarkdown_2.7          GetoptLong_1.0.5      
##  [91] locfit_1.5-9.4         grid_4.0.3             data.table_1.14.0     
##  [94] blob_1.2.1             digest_0.6.27          xtable_1.8-4          
##  [97] tidyr_1.1.3            munsell_0.5.0          registry_0.5-1        
## [100] viridisLite_0.3.0      bslib_0.2.4