Yet, we have to try other correlation methods on the continuous space, or consider other metrics if working on the discrete space. Unbalanced Wassertein distance, or relatives, for distinct input and output dimensions.
Plot weighted undirected compound graphs with igraph::graph_from_adjacency_matrix in Figure 3.7, filtering out pairwise connections between 2 drugs if the \(p\)-value is not significant and absolute correlation score is below 0.8:
Code
#| label: fig-igraph-drug## 1) Compute correlation matrix and p-values ----cor_res<-Hmisc::rcorr(se_binarised_compound_mat, type ="pearson")cor_binarised_compound<-cor_res$rpval_binarised_compound<-cor_res$Padj_mat<-cor_binarised_compoundadj_mat[pval_binarised_compound>0.05/ncol(cor_res)]<-0## 2) build igraph adjacency matrix ----compound_graph<-igraph::graph_from_adjacency_matrix(adjmatrix=adj_mat, weighted =TRUE, diag =FALSE, mode ="undirected")## 3) igraph customisation ----compound_graph$date<-today_dateE(compound_graph)$color<-if_else(E(compound_graph)$weight>0, "red", "blue")E(compound_graph)$weight<-abs(E(compound_graph)$weight)layout_graph<-igraph::layout_with_fr(compound_graph, niter =500)# graph dimension sizesgraph_width<-range(layout_graph[,1])|>diff()graph_height<-range(layout_graph[,2])|>diff()aspect_ratio<-graph_width/graph_heightvertex_structure<-se_binarised_pheno_data_compound|>as.data.frame()|>dplyr::mutate(color =if_else(Pathway=="EGFR", "green", "yellow"))igraph::V(compound_graph)$color<-vertex_structure$colorpdf(paste0("figures/compounds/compound_graph_", today_date, ".pdf"), width =14*aspect_ratio, height =14, useDingbats =TRUE, compress =FALSE)plot(compound_graph, layout =layout_graph, vertex.size =10,## vertex.label.dist= 2, main ="Compound network interaction. In green, drugs related with the EGFR mechanism, and in yellow other pathways. Edge widths are proportional to the coefficient of correlation.", edge.width =igraph::E(compound_graph)$weight*20, vertex.label.cex =0.9, curved =0.2)dev.off()## png ## 2## 4) export PNG and readable graph formats for Neo4Jpng(paste0("figures/compounds/compound_graph_", today_date, ".png"), width =14*aspect_ratio, height =14, res =200, units =c("in"))plot(compound_graph, layout =layout_graph, vertex.size =10,## vertex.label.dist= 2, main ="Compound network interaction. In green, drugs related with the EGFR mechanism, and in yellow other pathways. Edge widths are proportional to the coefficient of correlation.", edge.width =igraph::E(compound_graph)$weight*20, vertex.label.cex =0.9, curved =0.2)dev.off()## png ## 2knitr::include_graphics(paste0("figures/compounds/compound_graph_", today_date, ".png"), dpi =200, auto_pdf =TRUE)igraph::write_graph(graph =compound_graph, file =paste0("./results/compounds/compound_network_", today_date, ".graphml"), format ="graphml")
Figure 3.7: Drug-drug network interactions, at the compound level.
3.3 Compute Cell Lines Similarities
3.3.1 Cell Line by Compound
Code
se_binarised_compound_batch_fac<-apply(se_binarised_compound_batch_mat, 2, as.character)## Heatmap annotationha<-ComplexHeatmap::HeatmapAnnotation(df =se_binarised_pheno_data_compound_batch|>as.data.frame()|>dplyr::select(Batch_ID, Pathway, Compound))heatmap_cell_lines_by_sample<-ComplexHeatmap::Heatmap(se_binarised_compound_batch_fac, col =c("TRUE"="red", "FALSE"="blue"), name ="Heatmap: cell-line by sample", show_row_names =FALSE, row_dend_reorder =TRUE,## clustering_distance_rows = "pearson", show_row_dend =FALSE, column_dend_reorder =TRUE, show_column_names =TRUE, column_names_gp =gpar(fontsize =6), column_names_rot =45, top_annotation =ha,## matrix size width =ncol(se_binarised_compound_batch_fac)*unit(3, "mm"), height =nrow(se_binarised_compound_batch_fac)*unit(0.3, "mm"), use_raster =TRUE)size_heatmap<-calc_ht_size(heatmap_cell_lines_by_sample)padding_heatmap<-unit(c(2, 10, 2, 2), "mm")## 2) Save png and pdf outputspng(paste0("figures/cell_lines/heatmap_cell_lines_by_samples_", today_date,".png"), res =50, width =size_heatmap$width, height =size_heatmap$height, units =c("in"))heatmap_cell_lines_by_sample|>ComplexHeatmap::draw(padding =padding_heatmap)dev.off()## png ## 2knitr::include_graphics(paste0("figures/cell_lines/heatmap_cell_lines_by_samples_", today_date,".png"), auto_pdf =TRUE, dpi =50)ggsave(paste0("figures/cell_lines/heatmap_cell_lines_by_samples_", today_date,".pdf"),heatmap_cell_lines_by_sample|>ComplexHeatmap::draw(padding =padding_heatmap)|>grid::grid.grabExpr(), dpi =200, limitsize =FALSE, width =size_heatmap$width, height =size_heatmap$height, units =c("in"))
Figure 3.8: Heatmap cell lines by samples, averaging over replicates.
Gehlenborg, Nils, and Bang Wong. 2012. ‘Mapping Quantitative Data to Color’. Nature Methods 9 (8): 769–69. https://doi.org/10.1038/nmeth.2134.