Check for proper loading of all packages. Otherwise, look for the vignettes and install the packages adequately.
#if (!require("BiocManager", quietly = TRUE))
# install.packages("BiocManager")
#BiocManager::install("EWCE",dependencies=T)
#BiocManager::install("multiMiR",dependencies=T)
#BiocManager::install("celldex",dependencies=T)
library(multiMiR)
library(EWCE)
library(celldex)
library(ggplot2)
Elapsed time: 12.886 seconds
For this example, we use a random list of murine microRNAs saved on the miRs object. All microRNAs are reported as MIMAT codes. For more information take a look at the miRbase database
miRs<-c("MIMAT0000521","MIMAT0000522","MIMAT0000523","MIMAT0000383","MIMAT0000524",
"MIMAT0000525","MIMAT0000121","MIMAT0000122","MIMAT0000123","MIMAT0000655",
"MIMAT0000133","MIMAT0000616","MIMAT0000546","MIMAT0004856","MIMAT0000385",
"MIMAT0000386","MIMAT0000647","MIMAT0000648","MIMAT0000208","MIMAT0005836",
"MIMAT0015644","MIMAT0005837","MIMAT0005843","MIMAT0005847","MIMAT0005849",
"MIMAT0005850","MIMAT0005852","MIMAT0005856")
We will use the function get_multimir to get the
corresponding miRNA-gene database for selected miRNAs. Please check that
we can opt for validated (table = 'validated') or
predicted targets.
multimir_results <- get_multimir(org = 'mmu', #Organism-dependent (Mus musculus - mmu)
mirna = miRs,
table = 'validated',
summary = TRUE)
## Searching mirecords ...
## Searching mirtarbase ...
## Searching tarbase ...
Elapsed time: 2.224 seconds
In this step, we will download data from the ImmGenData and set two information levels (‘main’ and ‘fine’).
#Download data
ref.se <- celldex::ImmGenData(cell.ont = "all")
ref.se@NAMES->rownames(ref.se@assays@data$logcounts)
#Correct gene names
ref.se@assays@data$logcounts = fix_bad_mgi_symbols(ref.se@assays@data$logcounts)
## Warning in fix_bad_mgi_symbols(ref.se@assays@data$logcounts): Possible presence
## of excel corrupted date-like genes: Marcksl1-ps3
#Generate celltype
annotLevels <- list(level1class=ref.se@colData$label.main,
level2class=ref.se@colData$label.fine)
fNames_immgen <- EWCE::generate_celltype_data(
exp = ref.se@assays@data$logcounts,
annotLevels = annotLevels,
groupName = "ImmGenData")
ctd_immGenData <- EWCE::load_rdata(fNames_immgen)
Elapsed time: 1.174 seconds
# Test first plot
plt_exp <- EWCE::plot_ctd(ctd = ctd_immGenData,
level = 1,
genes = unique(multimir_results@data$target_symbol)[1:10],
metric = "mean_exp")
Elapsed time: 0.88 seconds
Now, we will look for enriched cell types in our miRNA target list.
### Looking for enriched cell lines
rm(merged_results)
## Warning in rm(merged_results): objeto 'merged_results' não encontrado
for(i in 1:length(miRs)){ ## Check for errors in annotation
print(i)
length(unique(multimir_results@data[which(multimir_results@data$mature_mirna_acc==miRs[i]),]$target_symbol)%in% rownames(ctd_immGenData[[1]]$mean_exp))
if(length(unique(multimir_results@data[which(multimir_results@data$mature_mirna_acc==miRs[i]),]$target_symbol))>4){
full_results <- EWCE::bootstrap_enrichment_test(sct_data = ctd_immGenData,verbose=F,
sctSpecies = "mouse",
genelistSpecies = "mouse",
hits = unique(multimir_results@data[which(multimir_results@data$mature_mirna_acc==miRs[i]),]$target_symbol),
reps = 100,
annotLevel = 1 ##CHECK 1 or 2
)
if(!exists("merged_results")){
data.frame(full_results$results,
list=miRs[i])->merged_results
}else{
rbind(merged_results,data.frame(full_results$results,
list=miRs[i]))->merged_results
}
}
}
## [1] 1
## [1] 2
## [1] 3
## [1] 4
## [1] 5
## [1] 6
## [1] 7
## [1] 8
## [1] 9
## [1] 10
## [1] 11
## [1] 12
## [1] 13
## [1] 14
## [1] 15
## [1] 16
## [1] 17
## [1] 18
## [1] 19
## [1] 20
## [1] 21
## [1] 22
## [1] 23
## [1] 24
## [1] 25
## [1] 26
## [1] 27
## [1] 28
Elapsed time: 3.244 seconds
knitr::kable(full_results$results)
| CellType | annotLevel | p | fold_change | sd_from_mean | q | |
|---|---|---|---|---|---|---|
| Stem_cells | Stem_cells | 1 | 0.00 | 1.0184441 | 4.4574324 | 0.0000000 |
| B_cells | B_cells | 1 | 0.00 | 1.0185012 | 4.2899707 | 0.0000000 |
| T_cells | T_cells | 1 | 0.01 | 1.0104626 | 2.4567476 | 0.0666667 |
| Tgd | Tgd | 1 | 0.02 | 1.0084925 | 2.0867991 | 0.1000000 |
| Mast_cells | Mast_cells | 1 | 0.04 | 1.0106219 | 1.7912822 | 0.1600000 |
| B_cells,_pro | B_cells,_pro | 1 | 0.09 | 1.0063710 | 1.3644206 | 0.3000000 |
| NKT | NKT | 1 | 0.16 | 1.0047384 | 1.0031300 | 0.4571429 |
| DC | DC | 1 | 0.19 | 1.0031293 | 0.8568343 | 0.4750000 |
| Macrophages | Macrophages | 1 | 0.40 | 1.0009862 | 0.2219607 | 0.8000000 |
| NK_cells | NK_cells | 1 | 0.40 | 1.0007520 | 0.1670678 | 0.8000000 |
| Endothelial_cells | Endothelial_cells | 1 | 0.49 | 0.9998331 | -0.0260453 | 0.8909091 |
| Epithelial_cells | Epithelial_cells | 1 | 0.60 | 0.9975150 | -0.3423916 | 0.9800000 |
| Monocytes | Monocytes | 1 | 0.84 | 0.9950521 | -1.1065752 | 0.9800000 |
| ILC | ILC | 1 | 0.90 | 0.9951552 | -1.2918978 | 0.9800000 |
| Neutrophils | Neutrophils | 1 | 0.95 | 0.9904220 | -1.5749126 | 0.9800000 |
| Fibroblasts | Fibroblasts | 1 | 0.95 | 0.9891905 | -1.5850545 | 0.9800000 |
| Microglia | Microglia | 1 | 0.96 | 0.9889706 | -1.9896712 | 0.9800000 |
| Stromal_cells | Stromal_cells | 1 | 0.97 | 0.9852485 | -1.9237129 | 0.9800000 |
| Basophils | Basophils | 1 | 0.97 | 0.9878214 | -2.0302665 | 0.9800000 |
| Eosinophils | Eosinophils | 1 | 0.98 | 0.9885307 | -2.2234537 | 0.9800000 |
Finally, let’s plot our enrichment graph
# For the last miRNA evaluated
EWCE::ewce_plot(total_res = full_results$results,
mtc_method = "BH",
ctd = ctd_immGenData,make_dendro = F)
## $plain
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## not found in Windows font database
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
# Summarizing all findings
merged_results%>%
dplyr::filter(CellType %in% unique(merged_results[which(merged_results$q<0.01),]$CellType),
list %in% unique(merged_results[which(merged_results$q<0.01),]$list))%>%
dplyr::mutate(q=p.adjust(p,"BH"),
abs_sd=abs(sd_from_mean),
y_ast=sd_from_mean*1.05,
ast_q=ifelse(q<0.001,"*",
ifelse(q<0.01,"",ifelse(q<0.05,"",""))))%>%
ggplot()+
geom_hline(yintercept = 4,color="#E1E1E1",linetype="dashed") +
geom_bar(aes_string(x='CellType',y='abs_sd',fill="abs_sd"),stat="identity") +
theme_bw(base_size = 12, base_family = "Helvetica") +
theme(panel.grid.major = element_line(size = .5, color = "white"),
axis.line = element_line(size=.7, color = "black"), text = element_text(size=14),
axis.title.y = element_text(vjust = 0.6))+
#theme(plot.margin=unit(c(0,0,0,0),"mm"))+
theme(panel.border = element_rect(colour = "black", fill=NA, size=1),
axis.text.x = element_text(angle = 55, hjust = 1,size=10))+
xlab("") +
geom_text(aes_string(label="ast_q",x="CellType",y="y_ast"),size=6)+
scale_y_continuous(breaks=c(0,4,8),limits = c(0,10)) +
theme(strip.text.y = element_text(angle = 0),strip.background =element_rect(fill="white")) +
#coord_cartesian(ylim = c(0,1.1*upperLim))+
ylab("Std.Devs. from the mean") +
theme(plot.margin = unit(c(1,1,1,5), "cm"))+ # + theme(legend.position="none")
facet_grid("list ~ .",scales="free", space = "free_x")+
paletteer::scale_fill_paletteer_c("viridis::plasma")+
labs(fill="Absolute \nvalues\n (Std. Dev.)")->p
## Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
## ℹ Please use tidy evaluation idioms with `aes()`.
## ℹ See also `vignette("ggplot2-in-packages")` for more information.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: The `size` argument of `element_line()` is deprecated as of ggplot2 3.4.0.
## ℹ Please use the `linewidth` argument instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0.
## ℹ Please use the `linewidth` argument instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
p
## Warning: Removed 10 rows containing missing values or values outside the scale range
## (`geom_bar()`).
## Warning: Removed 105 rows containing missing values or values outside the scale range
## (`geom_text()`).
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## font family not found in Windows font database