In [1]:
library(ArchR)
library(here)
library(Seurat)
library(SeuratDisk)
library(SingleCellExperiment)
options(repr.plot.width=15, repr.plot.height=11)
## add general functions at the top of the R scripts
ss <- function(x, pattern, slot = 1, ...) { sapply(strsplit(x = x, split = pattern, ...), '[', slot) }
                                                   / |
                                                 /    \
            .                                  /      |.
            \\\                              /        |.
              \\\                          /           `|.
                \\\                      /              |.
                  \                    /                |\
                  \\#####\           /                  ||
                ==###########>      /                   ||
                 \\##==......\    /                     ||
            ______ =       =|__ /__                     ||      \\\
        ,--' ,----`-,__ ___/'  --,-`-===================##========>
       \               '        ##_______ _____ ,--,__,=##,__   ///
        ,    __==    ___,-,__,--'#'  ==='      `-'    | ##,-/
        -,____,---'       \\####\\________________,--\\_##,/
           ___      .______        ______  __    __  .______      
          /   \     |   _  \      /      ||  |  |  | |   _  \     
         /  ^  \    |  |_)  |    |  ,----'|  |__|  | |  |_)  |    
        /  /_\  \   |      /     |  |     |   __   | |      /     
       /  _____  \  |  |\  \\___ |  `----.|  |  |  | |  |\  \\___.
      /__/     \__\ | _| `._____| \______||__|  |__| | _| `._____|
    

ArchR : Version 1.0.2
For more information see our website : www.ArchRProject.com
If you encounter a bug please report : https://github.com/GreenleafLab/ArchR/issues

Loading Required Packages...

	Loading Package : grid v4.3.1

	Loading Package : gridExtra v2.3

	Loading Package : gtools v3.9.4

	Loading Package : gtable v0.3.4

	Loading Package : ggplot2 v3.5.0

Warning message:
“package ‘ggplot2’ was built under R version 4.3.2”
	Loading Package : magrittr v2.0.3

	Loading Package : plyr v1.8.9

	Loading Package : stringr v1.5.1

Warning message:
“package ‘stringr’ was built under R version 4.3.2”
	Loading Package : data.table v1.15.2

Warning message:
“package ‘data.table’ was built under R version 4.3.3”
	Loading Package : matrixStats v1.2.0

Warning message:
“package ‘matrixStats’ was built under R version 4.3.2”
	Loading Package : S4Vectors v0.40.2

Warning message:
“package ‘S4Vectors’ was built under R version 4.3.2”
Warning message:
“package ‘BiocGenerics’ was built under R version 4.3.2”
	Loading Package : GenomicRanges v1.54.1

Warning message:
“package ‘GenomicRanges’ was built under R version 4.3.2”
Warning message:
“package ‘IRanges’ was built under R version 4.3.2”
Warning message:
“package ‘GenomeInfoDb’ was built under R version 4.3.2”
	Loading Package : BiocGenerics v0.48.1

	Loading Package : Matrix v1.6.5

	Loading Package : Rcpp v1.0.12

Warning message:
“package ‘Rcpp’ was built under R version 4.3.2”
	Loading Package : SummarizedExperiment v1.32.0

Warning message:
“package ‘SummarizedExperiment’ was built under R version 4.3.2”
Warning message:
“package ‘MatrixGenerics’ was built under R version 4.3.2”
Warning message:
“package ‘Biobase’ was built under R version 4.3.2”
	Loading Package : rhdf5 v2.42.1

here() starts at /projects/pfenninggroup/singleCell/BICCN_mouse_CATlas_snATAC-seq


Attaching package: ‘here’


The following object is masked from ‘package:plyr’:

    here


Loading required package: SeuratObject

Loading required package: sp

Warning message:
“package ‘sp’ was built under R version 4.3.2”

Attaching package: ‘sp’


The following object is masked from ‘package:IRanges’:

    %over%



Attaching package: ‘SeuratObject’


The following object is masked from ‘package:SummarizedExperiment’:

    Assays


The following object is masked from ‘package:GenomicRanges’:

    intersect


The following object is masked from ‘package:GenomeInfoDb’:

    intersect


The following object is masked from ‘package:IRanges’:

    intersect


The following object is masked from ‘package:S4Vectors’:

    intersect


The following object is masked from ‘package:BiocGenerics’:

    intersect


The following object is masked from ‘package:base’:

    intersect



Attaching package: ‘Seurat’


The following object is masked from ‘package:SummarizedExperiment’:

    Assays


Registered S3 method overwritten by 'SeuratDisk':
  method            from  
  as.sparse.H5Group Seurat

In [2]:
#archr settings
addArchRGenome("mm10")
addArchRThreads(threads = 8)
Setting default genome to Mm10.

Setting default number of Parallel threads to 8.

In [3]:
PROJNAME = "BICCN_mouse_Str_snATAC2_MSN"
PROJPATH = here(here("data/tidy_data/ArchRProjects"),PROJNAME) #subset proj name
PROJPATH
proj = loadArchRProject(PROJPATH)
'/projects/pfenninggroup/singleCell/BICCN_mouse_CATlas_snATAC-seq/data/tidy_data/ArchRProjects/BICCN_mouse_Str_snATAC2_MSN'
Successfully loaded ArchRProject!


                                                   / |
                                                 /    \
            .                                  /      |.
            \\\                              /        |.
              \\\                          /           `|.
                \\\                      /              |.
                  \                    /                |\
                  \\#####\           /                  ||
                ==###########>      /                   ||
                 \\##==......\    /                     ||
            ______ =       =|__ /__                     ||      \\\
        ,--' ,----`-,__ ___/'  --,-`-===================##========>
       \               '        ##_______ _____ ,--,__,=##,__   ///
        ,    __==    ___,-,__,--'#'  ==='      `-'    | ##,-/
        -,____,---'       \\####\\________________,--\\_##,/
           ___      .______        ______  __    __  .______      
          /   \     |   _  \      /      ||  |  |  | |   _  \     
         /  ^  \    |  |_)  |    |  ,----'|  |__|  | |  |_)  |    
        /  /_\  \   |      /     |  |     |   __   | |      /     
       /  _____  \  |  |\  \\___ |  `----.|  |  |  | |  |\  \\___.
      /__/     \__\ | _| `._____| \______||__|  |__| | _| `._____|
    

In [4]:
p <- plotEmbedding( ArchRProj = proj, colorBy = "cellColData", name = c('Sample', 'SubRegion', 'ClustersX330'), embedding = "UMAPH330") 
p3 <- 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())
})
do.call(cowplot::plot_grid, c(list(ncol = 3),p3))
ArchR logging to : ArchRLogs/ArchR-plotEmbedding-69a94856ba84-Date-2024-03-20_Time-17-55-18.832757.log
If there is an issue, please report to github with logFile!

Getting UMAP Embedding

ColorBy = cellColData

Plotting Embedding

1 
2 
3 


ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-69a94856ba84-Date-2024-03-20_Time-17-55-18.832757.log

Warning message:
“The `<scale>` argument of `guides()` cannot be `FALSE`. Use "none" instead as
of ggplot2 3.3.4.”
No description has been provided for this image
In [5]:
markMSN1 = c('Drd1','Tac1', 'Pdyn', 'Drd2','Adora2a','Penk') # D1 & D2 markers

# D1 MSN
p <- plotEmbedding( ArchRProj = proj, colorBy = "GeneScoreMatrix", 
                    name = markMSN1, embedding = "UMAPH330", imputeWeights = NULL) # 
p1 <- 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())
})
do.call(cowplot::plot_grid, c(list(ncol = 3),p1))
ArchR logging to : ArchRLogs/ArchR-plotEmbedding-69a97f154fc1-Date-2024-03-20_Time-17-56-28.318016.log
If there is an issue, please report to github with logFile!

Getting UMAP Embedding

ColorBy = GeneScoreMatrix

Getting Matrix Values...

2024-03-20 17:56:28.690296 : 



Plotting Embedding

1 
2 
3 
4 
5 
6 


ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-69a97f154fc1-Date-2024-03-20_Time-17-56-28.318016.log

No description has been provided for this image
In [6]:
markMSN2 = c('Drd1', 'Drd2', 'Foxp2', 'Grm8','Tshz1', 'Drd3')# eSPN, D1/D2, IC markers

# D2 MSN
p <- plotEmbedding( ArchRProj = proj, colorBy = "GeneScoreMatrix", 
                    name = markMSN2, embedding = "UMAPH330", imputeWeights = NULL)
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())
})
do.call(cowplot::plot_grid, c(list(ncol = 3),p2))
ArchR logging to : ArchRLogs/ArchR-plotEmbedding-69a93f088b5d-Date-2024-03-20_Time-17-57-12.553345.log
If there is an issue, please report to github with logFile!

Getting UMAP Embedding

ColorBy = GeneScoreMatrix

Getting Matrix Values...

2024-03-20 17:57:13.002568 : 



Plotting Embedding

1 
2 
3 
4 
5 
6 


ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-69a93f088b5d-Date-2024-03-20_Time-17-57-12.553345.log

No description has been provided for this image
In [19]:
## make the plots
cols1 = setNames(RColorBrewer::brewer.pal(8,'Paired')[c(2,4,6,8)], c('D1', 'eSPN', 'D2', 'IC'))

cols2 = setNames(RColorBrewer::brewer.pal(7,'Paired'), 
                c('D1-Matrix', 'D1-Striosome', 'D1-NUDAP',  'D1/D2H', 'D2-Matrix', 'D2-Striosome', 'IC'))

cols = c(cols1, cols2)

p <- plotEmbedding(ArchRProj = proj, colorBy = "cellColData", 
                   name = c('integrated_clusters', 'integrated_subclusters'), 
                   embedding = "UMAPH330", pal = cols) 

       
p2 <- lapply(p, function(x){
  x + theme_ArchR(baseSize = 12) + 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(), 
            legend.text=element_text(size= 12)) + 
    guides(color = guide_legend(override.aes = list(size=5)))
})
do.call(cowplot::plot_grid, c(list(ncol = 2),p2))
ArchR logging to : ArchRLogs/ArchR-plotEmbedding-69a977784e28-Date-2024-03-20_Time-18-05-55.974125.log
If there is an issue, please report to github with logFile!

Getting UMAP Embedding

ColorBy = cellColData

Plotting Embedding

1 
2 


ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-69a977784e28-Date-2024-03-20_Time-18-05-55.974125.log

No description has been provided for this image
In [39]:
markerGenes  <- c( "Drd1", "Drd2", "Drd3", "Foxp2", 'Tshz1')

p <- plotBrowserTrack( 
    ArchRProj = proj, groupBy = "integrated_clusters", geneSymbol = markerGenes, pal = cols,
    upstream = 500000, downstream = 500000)
ArchR logging to : ArchRLogs/ArchR-plotBrowserTrack-69a92250cc8-Date-2024-03-20_Time-18-16-53.838136.log
If there is an issue, please report to github with logFile!

2024-03-20 18:16:54.109936 : Validating Region, 0.005 mins elapsed.

GRanges object with 5 ranges and 2 metadata columns:
      seqnames            ranges strand |     gene_id      symbol
         <Rle>         <IRanges>  <Rle> | <character> <character>
  [1]    chr13 54051183-54055658      - |       13488        Drd1
  [2]     chr9 49340662-49407214      + |       13489        Drd2
  [3]    chr16 43762221-43822932      + |       13490        Drd3
  [4]     chr6 14901349-15441977      + |      114142       Foxp2
  [5]    chr18 84011627-84086562      - |      110796       Tshz1
  -------
  seqinfo: 21 sequences from mm10 genome
2024-03-20 18:16:54.227037 : Adding Bulk Tracks (1 of 5), 0.007 mins elapsed.

2024-03-20 18:17:06.332072 : Adding Gene Tracks (1 of 5), 0.208 mins elapsed.

2024-03-20 18:17:07.614129 : Plotting, 0.23 mins elapsed.

2024-03-20 18:17:09.752565 : Adding Bulk Tracks (2 of 5), 0.265 mins elapsed.

2024-03-20 18:17:17.015864 : Adding Gene Tracks (2 of 5), 0.386 mins elapsed.

2024-03-20 18:17:19.02702 : Plotting, 0.42 mins elapsed.

2024-03-20 18:17:21.036778 : Adding Bulk Tracks (3 of 5), 0.453 mins elapsed.

2024-03-20 18:17:28.052652 : Adding Gene Tracks (3 of 5), 0.57 mins elapsed.

2024-03-20 18:17:28.272922 : Plotting, 0.574 mins elapsed.

2024-03-20 18:17:30.681391 : Adding Bulk Tracks (4 of 5), 0.614 mins elapsed.

2024-03-20 18:17:41.507341 : Adding Gene Tracks (4 of 5), 0.795 mins elapsed.

2024-03-20 18:17:41.725429 : Plotting, 0.798 mins elapsed.

2024-03-20 18:17:44.125337 : Adding Bulk Tracks (5 of 5), 0.838 mins elapsed.

2024-03-20 18:17:52.760377 : Adding Gene Tracks (5 of 5), 0.982 mins elapsed.

2024-03-20 18:17:52.982134 : Plotting, 0.986 mins elapsed.

ArchR logging successful to : ArchRLogs/ArchR-plotBrowserTrack-69a92250cc8-Date-2024-03-20_Time-18-16-53.838136.log

In [40]:
options(repr.plot.width=15, repr.plot.height=6)
grid::grid.draw(p$Drd1)
No description has been provided for this image
In [41]:
grid::grid.draw(p$Drd2)
No description has been provided for this image
In [42]:
grid::grid.draw(p$Drd3)
No description has been provided for this image
In [43]:
grid::grid.draw(p$Foxp2)
No description has been provided for this image
In [44]:
grid::grid.draw(p$Tshz1)
No description has been provided for this image
In [ ]: