Last updated: 2020-11-24

Checks: 7 0

Knit directory: QuRIE-seq_manuscript/

This reproducible R Markdown analysis was created with workflowr (version 1.6.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20201117) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 8d11c04. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/

Untracked files:
    Untracked:  code/template_script.R
    Untracked:  data/raw/
    Untracked:  output/MOFA_aIg.hdf5
    Untracked:  output/MOFA_aIg.rds
    Untracked:  output/MOFA_ibru.hdf5
    Untracked:  output/MOFA_ibru.rds
    Untracked:  output/data_weights_prot_fact1and3.csv
    Untracked:  output/metadata.csv
    Untracked:  output/paper_figures/
    Untracked:  output/seu_aIG_samples.rds
    Untracked:  output/seu_combined_filtered_normalized.rds
    Untracked:  output/seu_combined_raw.rds
    Untracked:  output/seu_ibru_samples.rds

Unstaged changes:
    Modified:   analysis/_site.yml

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/MOFAibru.Rmd) and HTML (docs/MOFAibru.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 8d11c04 Jessie van Buggenum 2020-11-24 Documentation Figure 3: ibrutinib data
html 2ffe38d Jessie van Buggenum 2020-11-17 Build site.
Rmd 4487750 Jessie van Buggenum 2020-11-17 basis set-up of page display
Rmd d9372d1 Jessie van Buggenum 2020-11-17 Publish the initial files for this website

source("code/load_packages.R")

panellabels <- c('a', 'b', 'c','d' , 'e', 'f', 'g', 'h', 'i', 'j', 'k')

add.textsize <- theme(axis.text.x = element_text(colour = 'black', size = 7),
          axis.text.y = element_text(colour = 'black',size=7),
          text = element_text(size=7),
          axis.text=element_text(size=7),
          plot.title = element_text(size=7)
          )

colorgradient6 <- c("#d4d4d3","#859FCA", "#4D7CC6" ,"#1F5284","#11304C", "#0C2236" )
colorgradient7 <- c(colorgradient6,"orange2")
colorsibru <- c(colorgradient7[c(1,2)],"#E69F00", colorgradient7[c(6)], "#D55E00","#ff0000")


labels.withibru <- c(0, 6, "6 \n+ibru", 180, "180\n+ibru")
labels.withibru.selected <- c(0, 6, "6 \n+ibru", 180, "180\n+ibru","180**\n+ibru")
seu_combined_selectsamples.withibru <- readRDS("output/seu_ibru_samples.rds")

proteins.all.withibru <- row.names(seu_combined_selectsamples.withibru[["PROT"]])

meta.allcells.withibru <- seu_combined_selectsamples.withibru@meta.data %>%
  mutate(sample = rownames(seu_combined_selectsamples.withibru@meta.data))

seu_combined_selectsamples.withibru <- FindVariableFeatures(seu_combined_selectsamples.withibru, selection.method = "mvp", assay = "SCT.RNA", num.bin =20, mean.cutoff = c(0, 5), dispersion.cutoff = c(0.5,10), nfeatures =500, verbose = FALSE)

genes.variable <- seu_combined_selectsamples.withibru@assays$SCT.RNA@var.features[-grep("^MT", seu_combined_selectsamples.withibru@assays$SCT.RNA@var.features)] # without the mitochondrial genes 

seu_combined_selectsamples.withibru
An object of class Seurat 
16824 features across 4658 samples within 3 assays 
Active assay: SCT.RNA (8372 features, 2286 variable features)
 2 other assays present: RNA, PROT

MOFA analysis ibru data

Note, if mofa object was generated before, it will read the generated rds file. (this will speed-up the process of generating this html document if edits are required)

myfiles <- list.files(path="output/", pattern = ".rds$")

if("MOFA_ibru.rds" %in%  myfiles){
  
  mofa <- readRDS("output/MOFA_ibru.rds")} else { 

    ## Nested list of RNA and Protein data (retrieved from filtered Seurat object)    
     mofa <- create_mofa(list(
      "RNA" = as.matrix( seu_combined_selectsamples.withibru@assays$SCT.RNA@scale.data[genes.variable,] ),
      "PROT" = as.matrix( seu_combined_selectsamples.withibru@assays$PROT@scale.data[proteins.all.withibru,] ))
      )

     ## Default data, model and training options
     data_opts <- get_default_data_options(mofa)
     model_opts <- get_default_model_options(mofa)
     train_opts <- get_default_training_options(mofa)
     train_opts$seed <- 42 # use same seed for reproducibility
    
    mofa <- prepare_mofa(
      object = mofa,
      data_options = data_opts,
      model_options = model_opts,
      training_options = train_opts
      )

      mofa <- run_mofa(mofa, outfile = "output/MOFA_ibru.hdf5")
      mofa <- run_umap(mofa)
      samples_metadata(mofa) <- meta.allcells.withibru
      saveRDS(mofa, file= "output/MOFA_ibru.rds")
  
}

mofa
Trained MOFA with the following characteristics: 
 Number of views: 2 
 Views names: RNA PROT 
 Number of features (per view): 2263 80 
 Number of groups: 1 
 Groups names: group1 
 Number of samples (per group): 4658 
 Number of factors: 8 

Figure 3

Main

## UMAP
plot.umap.data <-  plot_dimred(mofa, method="UMAP", color_by = "condition",stroke = 0.001, dot_size =1, alpha = 0.2, return_data = T)

plot.umap.all <- ggplot(plot.umap.data, aes(x=x, y = y, fill = color_by))+
  geom_point(size = 0.7, alpha = 0.5, shape = 21, stroke = 0) +
  theme_half_open() +
  scale_fill_manual(values = colorsibru, labels = c(labels.withibru), name = "Time aIg \n(minutes)")+
   theme(legend.position="none")+
  add.textsize +
  scale_x_reverse()+
  scale_y_reverse()+
  labs(title = "Ibrutinib affects signal transduction \nat minutes and hour time-scale", x = "UMAP 1", y = "UMAP 2")

## UMAP legend
legend.umap <- get_legend( ggplot(plot.umap.data, aes(x=x, y = y, fill = color_by))+
  geom_point(size = 2, alpha = 0.5, shape = 21, stroke = 0) +
  theme_half_open() +
  scale_fill_manual(values = colorsibru, labels = c(labels.withibru), name ="Time aIg \n(minutes)",)+
   theme(legend.position="right")+
  add.textsize +
  scale_x_reverse()+
  scale_y_reverse()+
  labs(title = "Ibrutinib affects signal transduction at \nminute and hour timepoints after aIG stimulation", x = "UMAP 1", y = "UMAP 2"))
legend.umap <- as_ggplot(legend.umap)

## correlation time and factors
plot.correlation.covariates.withibru <- correlate_factors_with_covariates(mofa, 
  covariates = c("time", "inhibitor"),
  factors = 8:1,
  plot = "r"
)

plot.correlation.covariates.withibru <- ggcorrplot(plot.correlation.covariates.withibru, tl.col = "black", method = "square", lab = TRUE, ggtheme = theme_void, colors = c("orange3", "white", "orange3"), lab_size = 2.5) +
  add.textsize +
  labs(title = "Correlation\ncoefficient\n", y = "") +
  scale_y_discrete(labels = c("time\naIg\n","ibrutinib\ntreatment\n")) +
  coord_flip() +
  theme(axis.text.x=element_text(angle =0,hjust = 0.5), 
        axis.text.y=element_text(size = 5),
        legend.position="none",
        plot.title = element_text(hjust = 0.5))

## functions violin prots
f.violin <- function(data, feature){
  
  ggplot(subset(data)  , aes(x = as.factor(condition), y =get(noquote(feature)))) +
    annotate("rect",
          xmin = 4 - 0.45,
             xmax = 5 + 0.5,
           ymin = -5.5, ymax =5, fill = "lightblue",
           alpha = .4
  )+
  geom_violin(alpha = 0.9,aes(fill = condition))+
  geom_jitter(width = 0.05,size = 0.1, color = "black")+ 
  stat_summary(fun=median, geom="point", shape=95, size=2, inherit.aes = T, position = position_dodge(width = 0.9), color = "red")+
  theme_few()+
  labs(title = paste0(feature)) +
  scale_x_discrete(labels = labels.withibru, expand = c(0.1,0.1), name = "Time aIg (Minutes)") +
  scale_y_continuous(expand = c(0,0), name = "Counts (scaled)") +
  scale_color_manual(values = colorsibru, labels = c(labels.withibru), name = "Time aIg (Minutes)",)+ 
  scale_fill_manual(values = colorsibru, labels = c(labels.withibru), name = "Time aIg (Minutes)",) +
  add.textsize +
  theme(axis.ticks=element_line(color="black", size = 0.2),
        legend.position="none") 
}

## functions violin RNA
f.violin.rectlarge <- function(data, feature){
  
  ggplot(subset(data)  , aes(x = as.factor(condition), y =get(noquote(feature)))) +
    annotate("rect",
          xmin = 4 - 0.45,
             xmax = 5 + 0.5,
           ymin = -3, ymax = 15, fill = "lightblue",
           alpha = .4
  )+
  geom_violin(alpha = 0.9,aes(fill = condition))+
  geom_jitter(width = 0.05,size = 0.1, color = "black")+ 
  stat_summary(fun=median, geom="point", shape=95, size=2, inherit.aes = T, position = position_dodge(width = 0.9), color = "red")+
  theme_few()+
  labs(title = paste0(feature)) +
  scale_x_discrete(labels = labels.withibru, expand = c(0.1,0.1), name = "Time aIg (Minutes)") +
  scale_y_continuous(expand = c(0,0), name = "Counts (scaled)") +
  scale_color_manual(values = colorsibru, labels = c(labels.withibru), name = "Time aIg (Minutes)",)+ 
  scale_fill_manual(values = colorsibru, labels = c(labels.withibru), name = "Time aIg (Minutes)",) +
  add.textsize +
  theme(axis.ticks=element_line(color="black", size = 0.2),
        legend.position="none") 
}

## functions violin factors
f.violin.fact <- function(data = proteindata.subset, protein){
  
  ggplot(subset(data)  , aes(x = as.factor(condition), y =get(noquote(protein)))) +
    annotate("rect",
          xmin = 4 - 0.5,
             xmax = 5 + 0.5,
           ymin = -4.5, ymax = 4.5, fill = "lightblue",
           alpha = .4
  )+
    geom_hline(yintercept=0, linetype='dotted', col = 'black')+ 
  geom_violin(alpha = 0.9,aes(fill = condition))+
  geom_jitter(width = 0.05,size = 0.1, color = "black")+ 
  stat_summary(fun=median, geom="point", shape=95, size=2, inherit.aes = T, position = position_dodge(width = 0.9), color = "red")+
  theme_few()+
  ylab(paste0(protein)) +
  scale_x_discrete(labels = labels.withibru, expand = c(0.1,0.1), name = "Time aIg (Minutes)") +
    scale_y_continuous(expand = c(0,0), name = strsplit(protein, split = "\\.")[[1]][2]) +
  scale_color_manual(values = colorsibru, labels = c(labels.withibru), name = "Time aIg (Minutes)",)+ 
  scale_fill_manual(values = colorsibru, labels = c(labels.withibru), name = "Time aIg (Minutes)",) +
  add.textsize +
  theme(legend.position="none") 
}


## Factor data for violins
MOFAfactors<- as.data.frame(mofa@expectations$Z) %>%
  mutate(sample = rownames(as.data.frame(mofa@expectations$Z)[,1:mofa@dimensions$K])) 

MOFAfactors <- left_join(as.data.frame(MOFAfactors), meta.allcells.withibru)

factors_toplot <- c(colnames(MOFAfactors)[c(1:mofa@dimensions$K)])

## plot violin factors
for(i in factors_toplot) {
assign(paste0("plot.violin.factor.", i), f.violin.fact(data = MOFAfactors,protein = i)) 
}

plot.violin.factor1 <- plot.violin.factor.group1.Factor1 +
  theme(#axis.title.x=element_blank(),
        #axis.text.x=element_blank(),
        #axis.ticks.x=element_blank(),
        legend.position="none") +
  scale_y_reverse(expand = c(0,0), name = "Factor value")+
  labs(title = "Factor 1 \n'BCR signaling'")

plot.violin.factor3 <- plot.violin.factor.group1.Factor3 +
  theme(axis.title.y=element_blank(),
        #axis.text.y=element_blank(),
        #axis.ticks.y=element_blank(),
        legend.position="none") +
  scale_y_continuous(expand = c(0,0), name = "Factor 3 value")+
  labs(title = "Factor 3 \n'B-cell activation'")


plot.violin.factor5 <- plot.violin.factor.group1.Factor5 +
  theme(axis.title.y=element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank(),
        legend.position="none") +
  scale_y_continuous(expand = c(0,0), name = "Factor 5 value")+
  labs(title = "Factor 5 \n")

## Protein data for violins
proteindata <- as.data.frame(t(seu_combined_selectsamples.withibru@assays$PROT@scale.data)) %>%
  mutate(sample = rownames(t(seu_combined_selectsamples.withibru@assays$PROT@scale.data))) %>%
  left_join(meta.allcells.withibru, by = "sample")

proteinstoplot <- c("p-Erk1/2", "p-PLC-y2Y759", "p-BLNK", "p-CD79a", "p-Syk", "p-JAK1")

for(i in proteinstoplot) {
assign(paste0("plot.violin.prot.", i), f.violin(data = proteindata, feature = i))

}

`plot.violin.prot.p-Erk1/2` <- `plot.violin.prot.p-Erk1/2` +
  labs(title = "p-ERK1/2") 
  

## Data for violin genes
rnadata <- as.data.frame(t(seu_combined_selectsamples.withibru@assays$SCT.RNA@scale.data)) %>%
  mutate(sample = rownames(t(seu_combined_selectsamples.withibru@assays$SCT.RNA@scale.data))) %>%
  left_join(meta.allcells.withibru, by = "sample")

for(i in c("NEAT1", "NPM1", "BTF3", "RGS2", "RGS13","VEGFA")) {
assign(paste0("plot.violin.RNA.", i), f.violin.rectlarge(data = rnadata, feature = i))

}

## Enrichment analysis factor 5
weights.RNA <- get_weights(mofa, views = "RNA",as.data.frame = TRUE)

weights.RNA.filtered.f5 <- weights.RNA %>%
  mutate(Entrez = mapIds(org.Hs.eg.db, as.character(weights.RNA$feature), 'ENTREZID', 'SYMBOL'))  %>%
  filter(abs(value) >= 0.2 & factor == "Factor5") %>%
  mutate(sign = ifelse(value <= 0, "neg", "pos")) 

enriched.go.bp.fct5.clusterdposneg <- compareCluster(Entrez~factor+sign, data=weights.RNA.filtered.f5, fun='enrichGO', OrgDb='org.Hs.eg.db',ont= "BP",
                pAdjustMethod = "BH", readable = TRUE)

enriched.go.bp.fct5.clusterdposneg <- simplify(enriched.go.bp.fct5.clusterdposneg, cutoff=0.8, by="p.adjust", select_fun=min)


plot.enriched.go.f5.top5 <- dotplot(enriched.go.bp.fct5.clusterdposneg,x=~sign, showCategory = 5, by = "count") +
  scale_y_discrete(labels = c("negative regulation of G protein-coupled\nreceptor signaling pathway") , limits = "negative regulation of G protein-coupled receptor signaling pathway") +
  facet_grid(~factor) +
  add.textsize+ 
  scale_color_viridis(option="E", direction = -1) +
  scale_size_continuous(range=c(0.8, 2)) 

## Top enriched sets
topgeneset.fct5<- unlist(str_split(subset(enriched.go.bp.fct5.clusterdposneg@compareClusterResult, sign == "pos")$geneID, pattern = "/"))

topgeneset.fct5 = bitr(topgeneset.fct5, fromType="SYMBOL", toType="ENTREZID", OrgDb="org.Hs.eg.db")

bottomgeneset.fct5<- unlist(str_split(subset(enriched.go.bp.fct5.clusterdposneg@compareClusterResult, sign == "neg")[1:5,]$geneID, pattern = "/"))

bottomgeneset.fct5 = bitr(bottomgeneset.fct5, fromType="SYMBOL", toType="ENTREZID", OrgDb="org.Hs.eg.db")

## PROT factor 5 loadings
plotdata.rank.PROT.5<-plot_weights(mofa, 
  view = "PROT", 
  factors = c(5), 
  nfeatures = 4, 
  text_size = 1,
  manual = list(c("p-Erk1/2", "XBP1_PROT"),NULL), 
  color_manual = list("black","black"),
  return_data = TRUE
)

plotdata.rank.PROT.5<- plotdata.rank.PROT.5%>%
  mutate(Rank = 1:nrow(plotdata.rank.PROT.5),
         Weight = value, 
         colorvalue = ifelse(labelling_group == 3,"black", ifelse(labelling_group == 2, "black", "grey2")),
         highlights = ifelse(labelling_group >= 1, as.character(feature), "")
         )

plot.rank.PROT.5<- ggplot(plotdata.rank.PROT.5, aes(x=Rank, y = Weight, label = highlights)) +
  labs(title = "<p><span style='color:black'></span>  phospho-proteins<span style='color:black'><span style='color:blue4'></span> ",  #
       x= "Loading rank\n",
       y= "Factor 5 loading value") +
  geom_point(size=0.1, color =plotdata.rank.PROT.5$colorvalue) +
  geom_text_repel(size = 2, 
                  segment.size = 0.2, 
                  color =plotdata.rank.PROT.5$colorvalue,
                  nudge_x       = -1 - plotdata.rank.PROT.5$Weight,
                  direction     = "y",
                  hjust         = 0,
                  segment.color = "grey50")+
  theme_few()+
  add.textsize +
  scale_x_continuous() +
  add.textsize +
  theme(
    plot.title = element_markdown(),
    axis.text.x=element_blank(),
    axis.ticks.x=element_blank(),
    axis.text.y = element_blank(),
    axis.title.y = element_blank(),
    axis.ticks.y = element_blank()
        )+
  ylim(c(-1,1))


### RNA loadings
plotdata.rank.RNA.5<-plot_weights(mofa, 
  view = "RNA", 
  factors = c(5), 
  nfeatures = 2, 
  text_size = 1,
  manual = list(topgeneset.fct5$SYMBOL,NULL), 
  color_manual = list("black","black"),
  return_data = TRUE
)

plotdata.rank.RNA.5<- plotdata.rank.RNA.5%>%
  mutate(Rank = 1:nrow(plotdata.rank.RNA.5),
         Weight = value, 
         colorvalue = ifelse(labelling_group == 3,"black", ifelse(labelling_group == 2, "black", "grey2")),
         highlights = ifelse(labelling_group >= 1, as.character(feature), "")
         )

plot.rank.RNA.5<- ggplot(plotdata.rank.RNA.5, aes(x=Rank, y = Weight, label = highlights)) +
  labs(title = "Top loadings  <p><span style='color:black'></span> genes <span style='color:black'><span style='color:black'></span> ",  #
       x= "Loading rank\n",
       y= "Factor 5 loading value") +
  geom_point(size=0.1, color =plotdata.rank.RNA.5$colorvalue) +
  geom_text_repel(size = 2, 
                  segment.size = 0.2, 
                  color =plotdata.rank.RNA.5$colorvalue,
                  nudge_x       = -1 - plotdata.rank.RNA.5$Weight,
                  direction     = "y",
                  hjust         =  0,
                  segment.color = "grey50")+
  theme_few()+
  add.textsize +
  scale_x_continuous() +
  add.textsize +
  theme(
    plot.title = element_markdown()
  )  +
  theme(axis.text.x=element_blank(),
        axis.ticks.x=element_blank()
        )+
  ylim(c(-1,1))
Fig3.row1 <- plot_grid(plot.umap.all, legend.umap, NULL, plot.correlation.covariates.withibru, plot.violin.factor1,plot.violin.factor3,plot.violin.factor5, labels = c(panellabels[1],"",panellabels[2], "", panellabels[3]), label_size = 10, ncol =7, rel_widths = c(1.2,0.1,0.1,0.55,0.72,0.68,0.61))

Fig3.row2 <- plot_grid(plot.rank.RNA.5, plot.rank.PROT.5,plot.violin.RNA.RGS2, plot.violin.RNA.RGS13, `plot.violin.prot.p-Erk1/2`, labels = c(panellabels[4], "", panellabels[5], "", panellabels[6]), label_size = 10, ncol = 5,  rel_widths = c(0.8,0.66,1.2,1.2,1.2))


plot.Fig3 <- plot_grid(Fig3.row1, Fig3.row2, labels = c( "", ""), label_size = 10, ncol = 1, rel_heights =c(0.9,0.7,1))

ggsave(plot.Fig3,filename = "output/paper_figures/Fig3.pdf", width = 183, height = 122, units = "mm",  dpi = 300, useDingbats = FALSE)
ggsave(plot.Fig3, filename = "output/paper_figures/Fig3.png", width = 183, height = 122, units = "mm",  dpi = 300)

plot.Fig3

Figure 3. aIG stimultion in contect of Ibrutinib.

Supplementary MOFA model

## Variance per factor
plot.variance.perfactor.all <- plot_variance_explained(mofa, x="factor", y="view") +
    add.textsize +
    labs(title = "Variance explained by each factor per modality") 

## variance total
plot.variance.total <- plot_variance_explained(mofa, x="view", y="factor", plot_total = T)
plot.variance.total <- plot.variance.total[[2]] +
  add.textsize +
    labs(title = "Total \nvariance") +
  geom_text(aes(label=round(R2,1)), vjust=1.6, color="white", size=2.5)

## Significance correlation covariates
plot.heatmap.pval.covariates <- as.ggplot(correlate_factors_with_covariates(mofa, 
  covariates = c("time"),
  factors = 1:mofa@dimensions$K,
  fontsize = 7, 
  cluster_row = F,
  cluster_col = F
))+ 
  add.textsize +
  theme(axis.text.y=element_blank(),
        axis.text.x=element_blank(),
        plot.title = element_text(size=7, face = "plain"),
        )

## Factor values over time
plot.violin.factorall <- plot_factor(mofa, 
  factor = c(1:mofa@dimensions$K),
  color_by = "condition",
  dot_size = 0.2,      # change dot size
  dodge = T,           # dodge points with different colors
  legend = F,          # remove legend
  add_violin = T,      # add violin plots,
  violin_alpha = 0.9  # transparency of violin plots
) +   
  add.textsize +
  scale_color_manual(values=c(colorsibru, labels = c(labels), name = "Time aIg")) +
  scale_fill_manual(values=c(colorsibru, labels = c(labels), name = "Time aIg"))+
  labs(title = "Factor values per time-point of additional factors not correlating with time." ) +
  theme(axis.text.x=element_blank())

## Loadings factors stable protein

plot.rank.PROT.2.4to7 <- plot_weights(mofa, 
  view = "PROT", 
  factors = c(1:mofa@dimensions$K), 
  nfeatures = 3, 
  text_size = 1.5
) +   
  add.textsize +
  labs(title = "Top 3 Protein loadings per factor") +
  theme(axis.text.y=element_blank(),
        axis.ticks.y=element_blank()
)

## Loadings factors stable protein

plot.rank.RNA.2.4to7 <- plot_weights(mofa, 
  view = "RNA", 
  factors = c(1:mofa@dimensions$K), 
  nfeatures = 3, 
  text_size = 1.5
) +   
  add.textsize +
  labs(title = "Top 3 RNA loadings per factor") +
  theme(axis.text.y=element_blank(),
        axis.ticks.y=element_blank()
)

## correlation time and factors
plot.correlation.covariates <- correlate_factors_with_covariates(mofa, 
  covariates = c("time"),
  factors = mofa@dimensions$K:1,
  plot = "r"
)

plot.correlation.covariates <- ggcorrplot(plot.correlation.covariates, tl.col = "black", method = "square", lab = TRUE, ggtheme = theme_void, colors = c("#11304C", "white", "#11304C"), lab_size = 2.5) +
  add.textsize +
  labs(title = "Correlation of \nfactors with \ntime of treatment", y = "") +
  scale_y_discrete(labels = "") +
  coord_flip() +
  theme(axis.text.x=element_text(angle =0,hjust = 0.5), 
        axis.text.y=element_text(size = 5),
        legend.position="none",
        plot.title = element_text(hjust = 0.5))
Coordinate system already present. Adding new coordinate system, which will replace the existing one.
Fig.3.suppl.mofa.row1 <- plot_grid(plot.variance.perfactor.all, plot.variance.total,NULL, plot.heatmap.pval.covariates, labels = c(panellabels[1:3]), label_size = 10, ncol = 4, rel_widths = c(1.35, 0.27,0.2,0.38))

Fig.3.suppl.mofa.row2 <- plot_grid(plot.violin.factorall,legend.umap, labels = panellabels[4], label_size = 10, ncol = 2, rel_widths = c(1,0.1))



Suppl_mofa <- plot_grid(Fig.3.suppl.mofa.row1, Fig.3.suppl.mofa.row2, plot.rank.PROT.2.4to7, plot.rank.RNA.2.4to7, labels = c("","", panellabels[5:6]),label_size = 10, ncol = 1, rel_heights = c(1.45,1,1.1,1.1))


ggsave(Suppl_mofa, filename = "output/paper_figures/Fig3.Suppl_MOFAibru.pdf", width = 183, height = 220, units = "mm",  dpi = 300, useDingbats = FALSE)
ggsave(Suppl_mofa, filename = "output/paper_figures/Fig3.Suppl_MOFAibru.png", width = 183, height = 220, units = "mm",  dpi = 300)

Suppl_mofa

Supplementary Figure. MOFA model additional information

Enrichment genes factor 5 positve loadings (> 0.2).

# print positive enrichment
subset(enriched.go.bp.fct5.clusterdposneg@compareClusterResult, sign == "pos")
        Cluster  factor sign         ID
120 Factor5.pos Factor5  pos GO:0045744
                                                            Description
120 negative regulation of G protein-coupled receptor signaling pathway
    GeneRatio  BgRatio       pvalue  p.adjust qvalue     geneID Count
120       2/5 53/18670 7.863922e-05 0.0222549     NA RGS13/RGS2     2

Supplementary violins

Suppl.row1 <- plot_grid(`plot.violin.prot.p-PLC-y2Y759`, `plot.violin.prot.p-BLNK`,`plot.violin.prot.p-CD79a`,`plot.violin.prot.p-Syk`,`plot.violin.prot.p-JAK1`,labels = panellabels[1], label_size = 10, ncol = 5, rel_widths = c(1,1,1,1,1))

Suppl.row2 <- plot_grid(plot.violin.RNA.NEAT1, plot.violin.RNA.NPM1, plot.violin.RNA.BTF3,labels = panellabels[2], label_size = 10, ncol = 5, rel_widths = c(1,1,1,1,1))

Suppl_ibru_protsgenes <- plot_grid(Suppl.row1, Suppl.row2,label_size = 10, ncol = 1, rel_heights = c(1,1))

ggsave(Suppl_ibru_protsgenes, filename = "output/paper_figures/Fig3.suppl.violinsibru.pdf", width = 183, height = 122, units = "mm",  dpi = 300, useDingbats = FALSE)
ggsave(Suppl_ibru_protsgenes, filename = "output/paper_figures/Fig3.suppl.violinsibru.png", width = 183, height = 122, units = "mm",  dpi = 300)

Suppl_ibru_protsgenes

Supplementary Figure. Violin plots of highlighted phopho-proteins & genes


sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=English_Netherlands.1252  LC_CTYPE=English_Netherlands.1252   
[3] LC_MONETARY=English_Netherlands.1252 LC_NUMERIC=C                        
[5] LC_TIME=English_Netherlands.1252    

attached base packages:
 [1] parallel  stats4    grid      stats     graphics  grDevices utils    
 [8] datasets  methods   base     

other attached packages:
 [1] png_0.1-7                   forcats_0.5.0              
 [3] clusterProfiler_3.14.3      clusterProfiler.dplyr_0.0.2
 [5] enrichplot_1.6.1            org.Hs.eg.db_3.10.0        
 [7] AnnotationDbi_1.48.0        IRanges_2.20.2             
 [9] S4Vectors_0.24.4            Biobase_2.46.0             
[11] BiocGenerics_0.32.0         ggridges_0.5.2             
[13] cowplot_1.1.0               ggtext_0.1.0               
[15] ggplotify_0.0.5             ggcorrplot_0.1.3           
[17] ggrepel_0.8.2               ggpubr_0.4.0               
[19] scico_1.2.0                 MOFA2_1.1                  
[21] extrafont_0.17              patchwork_1.0.1            
[23] RColorBrewer_1.1-2          viridis_0.5.1              
[25] viridisLite_0.3.0           ggsci_2.9                  
[27] sctransform_0.3.1           ggthemes_4.2.0             
[29] matrixStats_0.57.0          kableExtra_1.2.1           
[31] gridExtra_2.3               Seurat_3.2.2               
[33] ggplot2_3.3.2               scales_1.1.1               
[35] tidyr_1.1.2                 dplyr_1.0.2                
[37] stringr_1.4.0               workflowr_1.6.1            

loaded via a namespace (and not attached):
  [1] reticulate_1.16       tidyselect_1.1.0      RSQLite_2.2.1        
  [4] htmlwidgets_1.5.2     BiocParallel_1.20.1   Rtsne_0.15           
  [7] munsell_0.5.0         codetools_0.2-16      ica_1.0-2            
 [10] future_1.19.1         miniUI_0.1.1.1        withr_2.3.0          
 [13] GOSemSim_2.12.1       colorspace_1.4-1      knitr_1.30           
 [16] rstudioapi_0.11       ROCR_1.0-11           ggsignif_0.6.0       
 [19] tensor_1.5            DOSE_3.12.0           Rttf2pt1_1.3.8       
 [22] listenv_0.8.0         labeling_0.4.2        git2r_0.27.1         
 [25] urltools_1.7.3        mnormt_2.0.2          polyclip_1.10-0      
 [28] farver_2.0.3          bit64_4.0.5           pheatmap_1.0.12      
 [31] rhdf5_2.30.1          rprojroot_1.3-2       vctrs_0.3.4          
 [34] generics_0.0.2        xfun_0.18             markdown_1.1         
 [37] R6_2.4.1              graphlayouts_0.7.0    rsvd_1.0.3           
 [40] fgsea_1.12.0          spatstat.utils_1.17-0 gridGraphics_0.5-0   
 [43] DelayedArray_0.12.3   promises_1.1.0        ggraph_2.0.3         
 [46] gtable_0.3.0          globals_0.13.1        goftest_1.2-2        
 [49] tidygraph_1.2.0       rlang_0.4.8           splines_3.6.3        
 [52] rstatix_0.6.0         extrafontdb_1.0       lazyeval_0.2.2       
 [55] europepmc_0.4         broom_0.7.1           BiocManager_1.30.10  
 [58] yaml_2.2.1            reshape2_1.4.4        abind_1.4-5          
 [61] backports_1.1.10      httpuv_1.5.2          qvalue_2.18.0        
 [64] gridtext_0.1.1        tools_3.6.3           psych_2.0.9          
 [67] ellipsis_0.3.1        Rcpp_1.0.4.6          plyr_1.8.6           
 [70] progress_1.2.2        purrr_0.3.4           prettyunits_1.1.1    
 [73] rpart_4.1-15          deldir_0.1-29         pbapply_1.4-3        
 [76] zoo_1.8-8             haven_2.3.1           cluster_2.1.0        
 [79] fs_1.4.1              magrittr_1.5          data.table_1.13.0    
 [82] DO.db_2.9             openxlsx_4.2.2        triebeard_0.3.0      
 [85] lmtest_0.9-38         RANN_2.6.1            tmvnsim_1.0-2        
 [88] whisker_0.4           fitdistrplus_1.1-1    hms_0.5.3            
 [91] mime_0.9              evaluate_0.14         xtable_1.8-4         
 [94] rio_0.5.16            readxl_1.3.1          compiler_3.6.3       
 [97] tibble_3.0.4          KernSmooth_2.23-16    crayon_1.3.4         
[100] htmltools_0.5.0       mgcv_1.8-31           later_1.0.0          
[103] DBI_1.1.0             tweenr_1.0.1          corrplot_0.84        
[106] MASS_7.3-53           rappdirs_0.3.1        Matrix_1.2-18        
[109] car_3.0-10            igraph_1.2.6          pkgconfig_2.0.3      
[112] rvcheck_0.1.8         foreign_0.8-75        plotly_4.9.2.1       
[115] xml2_1.3.2            webshot_0.5.2         rvest_0.3.6          
[118] digest_0.6.26         RcppAnnoy_0.0.16      spatstat.data_1.4-3  
[121] fastmatch_1.1-0       rmarkdown_2.4         cellranger_1.1.0     
[124] leiden_0.3.3          uwot_0.1.8            curl_4.3             
[127] shiny_1.5.0           lifecycle_0.2.0       nlme_3.1-144         
[130] jsonlite_1.7.1        Rhdf5lib_1.8.0        carData_3.0-4        
[133] pillar_1.4.6          lattice_0.20-38       GO.db_3.10.0         
[136] fastmap_1.0.1         httr_1.4.2            survival_3.1-8       
[139] glue_1.4.2            zip_2.1.1             spatstat_1.64-1      
[142] bit_4.0.4             ggforce_0.3.2         stringi_1.4.6        
[145] HDF5Array_1.14.4      blob_1.2.1            memoise_1.1.0        
[148] irlba_2.3.3           future.apply_1.6.0