9.5 Marker Genes Imputation with MAGIC

In the previous section, you may have noticed that some of the gene score plots appear quite variable. This is because of the sparsity of scATAC-seq data. We can use MAGIC to impute gene scores by smoothing signal across nearby cells. In our hands, this greatly improves the visual interpretation of gene scores. ArchR doesnt actually use the code in MAGIC to do this (you do not need to install the Rmagic package) but instead we have reimplemented the workflow within ArchR. We use the addImputeWeights() function to add impute weights to our ArchRProject.

projHeme2 <- addImputeWeights(projHeme2)
## ArchR logging to : ArchRLogs/ArchR-addImputeWeights-371b040a96ab2-Date-2022-12-23_Time-06-32-35.log
## If there is an issue, please report to github with logFile!
## 2022-12-23 06:32:36 : Computing Impute Weights Using Magic (Cell 2018), 0 mins elapsed.

These impute weights can then be passed to plotEmbedding() when plotting gene scores overlayed on the UMAP embedding.

markerGenes  <- c(
    "CD34",  #Early Progenitor
    "GATA1", #Erythroid
    "PAX5", "MS4A1", "MME", #B-Cell Trajectory
    "CD14", "MPO", #Monocytes
    "CD3D", "CD8A"#TCells
  )

p <- plotEmbedding(
    ArchRProj = projHeme2, 
    colorBy = "GeneScoreMatrix", 
    name = markerGenes, 
    embedding = "UMAP",
    imputeWeights = getImputeWeights(projHeme2)
)
## Getting ImputeWeights
## ArchR logging to : ArchRLogs/ArchR-plotEmbedding-371b04c243be5-Date-2022-12-23_Time-06-32-45.log
## If there is an issue, please report to github with logFile!
## Getting UMAP Embedding
## ColorBy = GeneScoreMatrix
## Getting Matrix Values...
## 2022-12-23 06:32:47 :
## 
## Imputing Matrix
## Using weights on disk
## Using weights on disk
## Plotting Embedding
## 1 2 3 4 5 6 7 8 9 
## ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-371b04c243be5-Date-2022-12-23_Time-06-32-45.log

As before, we can subset this plot list to select a specific gene.

p$CD14

Or we can plot all the marker genes at once using cowplot.

#Rearrange for grid plotting
p2 <- lapply(p, function(x){
    x + guides(color = FALSE, fill = FALSE) + 
    theme_ArchR(baseSize = 6.5) +
    theme(plot.margin = unit(c(0, 0, 0, 0), "cm")) +
    theme(
        axis.text.x=element_blank(), 
        axis.ticks.x=element_blank(), 
        axis.text.y=element_blank(), 
        axis.ticks.y=element_blank()
    )
})
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.
## `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.
## `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.
## `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.
## `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.
## `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.
## `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.
## `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.
## `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead.
do.call(cowplot::plot_grid, c(list(ncol = 3),p2))

To save an editable vectorized version of this plot, we use the plotPDF() function.

plotPDF(plotList = p, 
    name = "Plot-UMAP-Marker-Genes-W-Imputation.pdf", 
    ArchRProj = projHeme2, 
    addDOC = FALSE, width = 5, height = 5)
## Plotting Ggplot!
## Plotting Ggplot!
## Plotting Ggplot!
## Plotting Ggplot!
## Plotting Ggplot!
## Plotting Ggplot!
## Plotting Ggplot!
## Plotting Ggplot!
## Plotting Ggplot!