Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to link peaks to genes #1855

Open
zgb963 opened this issue Nov 26, 2024 · 10 comments
Open

Unable to link peaks to genes #1855

zgb963 opened this issue Nov 26, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@zgb963
Copy link

zgb963 commented Nov 26, 2024

Hello,

I've been following the Joint RNA and ATAC analysis: 10x multiomic tutorial on the Stuart Lab website to process output from the 10X Genomics Cellranger ARC pipeline. I've been trying to run the following steps in the 'Link peaks to genes' section for one of my sample Seurat objects and for one or two genes, but I keep getting errors and I'm not sure how to fix them in order to make coverage plots. Any insight on how to fix this would be appreciated, thanks.

# change from RNAseq assay to ATACseq assay
DefaultAssay(liftoff_1_MI5_V1_SO) <- "ATAC"

# first compute the GC content for each peak (worked! Got a warning though)
liftoff_1_MI5_V1_SO <- RegionStats(liftoff_1_MI5_V1_SO, genome = BSgenome.Mfascicularis.NCBI.5.0)
# Warning: Not all seqlevels present in supplied genome

liftoff_1_MI5_V1_SO <- LinkPeaks(
  object = liftoff_1_MI5_V1_SO,
  peak.assay = "ATAC",
  expression.assay = "SCT",
  genes.use = c("OSTN", "FOS")
)

Processed 35548 groups out of 35548. 100% done. Time elapsed: 3s. ETA: 0s.
Testing 1 genes and 210517 peaks
  |                                                  | 0 % ~calculating  Warning: Requested more features than present in supplied data.
            Returning 0 featuresError in density.default(x = query.feature[[featmatch]], kernel = "gaussian",  :
argument 'x' must be numeric

# > liftoff_1_MI5_V1_SO
# An object of class Seurat 
# 271812 features across 8787 samples within 3 assays 
# Active assay: ATAC (210519 features, 210519 variable features)
#  2 layers present: counts, data
#  2 other assays present: RNA, SCT
#  5 dimensional reductions calculated: pca, lsi, umap, umap.atac, wnn.umap


# check if genes present in SCT expression assay
# > all(c("OSTN", "FOS") %in% rownames(liftoff_1_MI5_V1_SO[["SCT"]]))
# [1] TRUE


# Check the peak identifiers in the ATAC assay
# > head(rownames(liftoff_1_MI5_V1_SO[["ATAC"]]))
# [1] "chr1-30919-31783" "chr1-32491-33425" "chr1-36538-37474" "chr1-54567-55405" "chr1-57748-58645" "chr1-61338-62189"

I then tried to make a coverage plot with just one gene, but I also got an error.

liftoff_1_MI5_V1_SO <- LinkPeaks(
  object = liftoff_1_MI5_V1_SO,
  peak.assay = "ATAC",
  expression.assay = "SCT",
  genes.use = c("OSTN")
)

Error in density.default(x = query.feature[[featmatch]], kernel = "gaussian",  : 
  argument 'x' must be numeric

When I set genes.use to NULL to determine genes from expression assay, I get a similar error

liftoff_1_MI5_V1_SO <- LinkPeaks(
  object = liftoff_1_MI5_V1_SO,
  peak.assay = "ATAC",
  expression.assay = "SCT",
  genes.use = NULL
)

# Testing 23041 genes and 210517 peaks
#   |                                                  | 0 % ~calculating  Warning: Requested more features than present in supplied data.
#             Returning 0 featuresError in density.default(x = query.feature[[featmatch]], kernel = "gaussian",  : 
#   argument 'x' must be numeric

Below is my R session info

sessionInfo()
R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.1 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: /UTC
tzcode source: system (glibc)

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

other attached packages:
 [1] ROCR_1.0-11                           KernSmooth_2.23-24                    fields_16.3                           viridisLite_0.4.2                    
 [5] spam_2.11-0                           DoubletFinder_2.0.4                   DropletQC_0.0.0.9000                  miQC_1.12.0                          
 [9] R.utils_2.12.3                        R.oo_1.27.0                           R.methodsS3_1.8.2                     flexmix_2.3-19                       
[13] lattice_0.22-5                        SoupX_1.6.2                           BSgenome.Mfascicularis.NCBI.5.0_1.4.2 txdbmaker_1.0.1                      
[17] GenomicFeatures_1.56.0                AnnotationDbi_1.66.0                  Biobase_2.64.0                        remotes_2.5.0                        
[21] devtools_2.4.5                        usethis_3.0.0                         doParallel_1.0.17                     iterators_1.0.14                     
[25] future_1.34.0                         foreach_1.5.2                         lubridate_1.9.3                       forcats_1.0.0                        
[29] stringr_1.5.1                         dplyr_1.1.4                           purrr_1.0.2                           readr_2.1.5                          
[33] tidyr_1.3.1                           tibble_3.2.1                          tidyverse_2.0.0                       ggplot2_3.5.1                        
[37] patchwork_1.3.0                       SeuratDisk_0.0.0.9021                 Seurat_5.1.0                          SeuratObject_5.0.2                   
[41] sp_2.1-4                              hdf5r_1.3.11                          Signac_1.14.0                         BSgenome_1.72.0                      
[45] rtracklayer_1.64.0                    BiocIO_1.14.0                         Biostrings_2.72.1                     XVector_0.44.0                       
[49] GenomicRanges_1.56.2                  GenomeInfoDb_1.40.1                   IRanges_2.38.1                        S4Vectors_0.42.1                     
[53] BiocGenerics_0.50.0                  

loaded via a namespace (and not attached):
  [1] fs_1.6.4                    matrixStats_1.4.1           spatstat.sparse_3.1-0       bitops_1.0-9                httr_1.4.7                  RColorBrewer_1.1-3         
  [7] profvis_0.4.0               tools_4.4.0                 sctransform_0.4.1           utf8_1.2.4                  R6_2.5.1                    lazyeval_0.2.2             
 [13] uwot_0.2.2                  urlchecker_1.0.1            withr_3.0.1                 prettyunits_1.2.0           gridExtra_2.3               SeuratWrappers_0.4.0       
 [19] progressr_0.14.0            cli_3.6.3                   spatstat.explore_3.3-2      fastDummies_1.7.4           spatstat.data_3.1-2         ggridges_0.5.6             
 [25] pbapply_1.7-2               Rsamtools_2.20.0            parallelly_1.38.0           sessioninfo_1.2.2           maps_3.4.2.1                rstudioapi_0.16.0          
 [31] RSQLite_2.3.8               generics_0.1.3              ica_1.0-3                   spatstat.random_3.3-2       Matrix_1.7-0                fansi_1.0.6                
 [37] abind_1.4-8                 lifecycle_1.0.4             yaml_2.3.10                 SummarizedExperiment_1.34.0 BiocFileCache_2.12.0        SparseArray_1.4.8          
 [43] Rtsne_0.17                  grid_4.4.0                  blob_1.2.4                  promises_1.3.0              crayon_1.5.3                miniUI_0.1.1.1             
 [49] cowplot_1.1.3               KEGGREST_1.44.1             pillar_1.9.0                knitr_1.48                  rjson_0.2.23                future.apply_1.11.2        
 [55] codetools_0.2-20            fastmatch_1.1-4             leiden_0.4.3.1              glue_1.8.0                  spatstat.univar_3.0-1       data.table_1.16.0          
 [61] vctrs_0.6.5                 png_0.1-8                   gtable_0.3.5                cachem_1.1.0                xfun_0.48                   S4Arrays_1.4.1             
 [67] mime_0.12                   survival_3.7-0              SingleCellExperiment_1.26.0 RcppRoll_0.3.1              ellipsis_0.3.2              fitdistrplus_1.2-1         
 [73] nlme_3.1-166                bit64_4.5.2                 filelock_1.0.3              progress_1.2.3              RcppAnnoy_0.0.22            irlba_2.3.5.1              
 [79] colorspace_2.1-1            DBI_1.2.3                   nnet_7.3-19                 tidyselect_1.2.1            bit_4.5.0                   compiler_4.4.0             
 [85] curl_5.2.3                  httr2_1.0.5                 xml2_1.3.6                  DelayedArray_0.30.1         plotly_4.10.4               scales_1.3.0               
 [91] lmtest_0.9-40               rappdirs_0.3.3              digest_0.6.37               goftest_1.2-3               spatstat.utils_3.1-0        rmarkdown_2.28             
 [97] htmltools_0.5.8.1           pkgconfig_2.0.3             MatrixGenerics_1.16.0       dbplyr_2.5.0                fastmap_1.2.0               rlang_1.1.4                
[103] htmlwidgets_1.6.4           UCSC.utils_1.0.0            shiny_1.9.1                 farver_2.1.2                zoo_1.8-12                  jsonlite_1.8.9             
[109] mclust_6.1.1                BiocParallel_1.38.0         RCurl_1.98-1.16             magrittr_2.0.3              modeltools_0.2-23           GenomeInfoDbData_1.2.12    
[115] dotCall64_1.2               munsell_0.5.1               Rcpp_1.0.13                 reticulate_1.39.0           stringi_1.8.4               zlibbioc_1.50.0            
[121] MASS_7.3-61                 plyr_1.8.9                  pkgbuild_1.4.4              listenv_0.9.1               ggrepel_0.9.6               deldir_2.0-4               
[127] splines_4.4.0               tensor_1.5                  hms_1.1.3                   igraph_2.0.3                spatstat.geom_3.3-3         RcppHNSW_0.6.0             
[133] biomaRt_2.60.1              reshape2_1.4.4              pkgload_1.4.0               XML_3.99-0.17               evaluate_1.0.0              BiocManager_1.30.25        
[139] tzdb_0.4.0                  httpuv_1.6.15               RANN_2.6.2                  polyclip_1.10-7             scattermore_1.2             rsvd_1.0.5                 
[145] xtable_1.8-4                restfulr_0.0.15             RSpectra_0.16-2             later_1.3.2                 memoise_2.0.1               GenomicAlignments_1.40.0   
[151] cluster_2.1.6               timechange_0.3.0            globals_0.16.3             
@zgb963 zgb963 added the bug Something isn't working label Nov 26, 2024
@nh-codem
Copy link

Have you encountered an issue where peaks and their linked genes are located on different chromosomes? @zgb963

@zgb963
Copy link
Author

zgb963 commented Dec 9, 2024

Have you encountered an issue where peaks and their linked genes are located on different chromosomes? @zgb963

Hi @nh-codem I'm not sure. How can I check for this? Have you run into this issue before?

@zgb963
Copy link
Author

zgb963 commented Dec 13, 2024

Hello @timoast I was able to fix the warning when running the RegionStats function by changing the seqlevel/chromosome level naming convention to UCSC style to match the UCSC style of the annotation stored in the sample seurat object.

# try this and then rerun RegionStats
seqlevelsStyle(BSgenome.Mfascicularis.NCBI.5.0) <- "UCSC"


# check seqlevels again
seqlevels(BSgenome.Mfascicularis.NCBI.5.0)

# 			[1] "chr1"                      "chr2"                      "chr3"                      "chr4"                      "chr5"                      "chr6
#   [997] "chrUn_AQIA01074376"        "chrUn_AQIA01074377"        "chrUn_AQIA01074378"        "chrUn_AQIA01074379"       
#   [ reached getOption("max.print") -- omitted 6601 entries ]


# change default assay in sample 1 to ATAC
DefaultAssay(liftoff_1_MI5_V1_SO) <- "ATAC"

# rerun this with the modified genome object (didn't get warning)
liftoff_1_MI5_V1_SO <- RegionStats(liftoff_1_MI5_V1_SO, genome = BSgenome.Mfascicularis.NCBI.5.0)

However, I'm still unable to run the `LinkPeaks' function without getting the same error

# check that active ATAC assay is in sample 1
liftoff_1_MI5_V1_SO


# An object of class Seurat 
# 271812 features across 8211 samples within 3 assays 
# Active assay: ATAC (210519 features, 210519 variable features)
#  2 layers present: counts, data
#  2 other assays present: RNA, SCT
#  5 dimensional reductions calculated: pca, lsi, umap, umap.atac, wnn.umap
# 


liftoff_1_MI5_V1_SO <- LinkPeaks(
  object = liftoff_1_MI5_V1_SO,
  peak.assay = "ATAC",
  expression.assay = "SCT",
  genes.use = c("OSTN")
)

# Testing 1 genes and 210505 peaks
#   |                                                  | 0 % ~calculating  Warning: Requested more features than present in supplied data.
#             Returning 0 featuresError in density.default(x = query.feature[[featmatch]], kernel = "gaussian",  : 
#   argument 'x' must be numeric


# testing 210,505 peaks but there are 210,519 variable features in object?


# try link peaks again without specifying a gene?



# > liftoff_1_MI5_V1_SO <- LinkPeaks(
# +     object = liftoff_1_MI5_V1_SO,
# +     peak.assay = "ATAC",
# +     expression.assay = "SCT")
# Testing 22897 genes and 210505 peaks
#   |                                                  | 0 % ~calculating  Error in density.default(x = query.feature[[featmatch]], kernel = "gaussian",  : 
#   argument 'x' must be numeric
# In addition: Warning message:
# In MatchRegionStats(meta.feature = meta.use, query.feature = pk.use[x,  :
#   Requested more features than present in supplied data.
#             Returning 0 features

@timoast
Copy link
Collaborator

timoast commented Jan 17, 2025

Hi, could you install from the develop branch and see if you still have this issue?

@zgb963
Copy link
Author

zgb963 commented Jan 17, 2025

Hi, could you install from the develop branch and see if you still have this issue?

Hi @timoast thanks for your message. I uninstalled the current release and installed the development version of Signac and re-ran Link Peaks, but unfortunately it still didn't work. Please see below. The data in all of the sample objects are numeric so I don't understand why I keep getting this error when linking peaks?

# uninstall
remove.packages("Signac")

# reinstall
devtools::install_github("stuart-lab/signac", ref = "develop")

# load
library(Signac)

First compute the GC content for each peak (worked without issues or warnings)

DefaultAssay(liftoff_1_MI5_V1_SO_filtered) <- "ATAC"

liftoff_1_MI5_V1_SO_filtered <- RegionStats(liftoff_1_MI5_V1_SO_filtered, genome = BSgenome.Mfascicularis.NCBI.5.0)

Link peaks to genes (OSTN) (got same error)

liftoff_1_MI5_V1_SO_filtered <- LinkPeaks(
  object = liftoff_1_MI5_V1_SO_filtered,
  peak.assay = "ATAC",
  expression.assay = "SCT",
  genes.use = c("OSTN")
)

Testing 1 genes and 210469 peaks
Error in density.default(x = query.feature[[featmatch]], kernel = "gaussian",  : 
  argument 'x' must be numeric

Link peaks to genes (GAPDH)

liftoff_1_MI5_V1_SO_filtered <- LinkPeaks(
  object = liftoff_1_MI5_V1_SO_filtered,
  peak.assay = "ATAC",
  expression.assay = "SCT",
  genes.use = c("GAPDH")
)


Testing 1 genes and 210469 peaks
  |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s  
No significant links found

Link peaks to genes (FGR)

liftoff_1_MI5_V1_SO_filtered <- LinkPeaks(
  object = liftoff_1_MI5_V1_SO_filtered,
  peak.assay = "ATAC",
  expression.assay = "SCT",
  genes.use = c("FGR")
)

Testing 0 genes and 210469 peaks
Error in LinkPeaks(object = liftoff_1_MI5_V1_SO_filtered, peak.assay = "ATAC",  : 
  Could not find gene coordinates for requested genes

Link peaks to genes (omit genes.use)

liftoff_1_MI5_V1_SO_filtered <- LinkPeaks(
  object = liftoff_1_MI5_V1_SO_filtered,
  peak.assay = "ATAC",
  expression.assay = "SCT"
)

Testing 22452 genes and 210469 peaks
  |                                                  | 0 % ~calculating  Warning: Requested more features than present in supplied data.
            Returning 0 featuresError in density.default(x = query.feature[[featmatch]], kernel = "gaussian",  : 
  argument 'x' must be numeric

Is data in SCT assay numberic? Yes

is_numeric_expression <- sapply(liftoff_1_MI5_V1_SO_filtered[["SCT"]]@data, is.numeric)
# Warning message:
# In .M2v(x) : sparse->dense coercion: allocating vector of size 1.5 GiB

is_numeric_expression
# [987] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
# [ reached getOption("max.print") -- omitted 196021430 entries ]

Is data in ATAC assay numeric? Yes

is_numeric_peaks <- sapply(liftoff_1_MI5_V1_SO_filtered[["ATAC"]]@data, is.numeric)

is_numeric_peaks

# [987] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#  [ reached getOption("max.print") -- omitted 1602890666 entries ]

Check if genes tested with LinkPeaks are in SCT assay/ATAC assay


genes_to_check <- c("OSTN", "GAPDH", "FGR")
genes_in_sct <- genes_to_check %in% rownames(liftoff_1_MI5_V1_SO_filtered[["SCT"]]@data)
genes_in_sct


genes_in_atac <- genes_to_check %in% rownames(liftoff_1_MI5_V1_SO_filtered[["ATAC"]]@data)
genes_in_atac

[1] TRUE TRUE TRUE
[1] FALSE FALSE FALSE

@timoast
Copy link
Collaborator

timoast commented Jan 31, 2025

I think the issue is the GC content metadata for some peaks seems to contain non-numeric data (likely NA).

Can you show the output of these lines:

md <- liftoff_1_MI5_V1_SO_filtered[['ATAC']][[]]
head(md)
md[is.na(md$GC.percent), ]

@zgb963
Copy link
Author

zgb963 commented Feb 1, 2025

I think the issue is the GC content metadata for some peaks seems to contain non-numeric data (likely NA).

Can you show the output of these lines:

md <- liftoff_1_MI5_V1_SO_filtered[['ATAC']][[]]
head(md)
md[is.na(md$GC.percent), ]

Ok, I've put pictures of what the 2nd and 3rd line outputs

head(md)

Image

md[is.na(md$GC.percent), ]

Image

@timoast
Copy link
Collaborator

timoast commented Feb 3, 2025

It looks like you have NA for all the peak sequence metadata. Maybe this was stored incorrectly when you ran RegionStats the first time with the wrong genome information (NCBI vs UCSC genome). Can you try re-creating your object and set the RegionStats information using the correct genome only, then check this sequence metadata again?

@zgb963
Copy link
Author

zgb963 commented Feb 6, 2025

It looks like you have NA for all the peak sequence metadata. Maybe this was stored incorrectly when you ran RegionStats the first time with the wrong genome information (NCBI vs UCSC genome). Can you try re-creating your object and set the RegionStats information using the correct genome only, then check this sequence metadata again?

Hi @timoast thanks for your message. Below I've put everything I've run and the order I've run them from the beginning of the tutorial up until linking peaks to genes. Everything else runs great up until that point

STEP 1 read in count matrices & atac fragments path

gc_liftoff_1MI5_matrix <- Read10X_h5("~/macaque_multiomics/cr-arc-1_MI5_V1_240716_macfas6liftoff_hg38gencodev47_basic/outs/filtered_feature_bc_matrix.h5")
gc_liftoff_1MI5_fragpath <- "~/macaque_multiomics/cr-arc-1_MI5_V1_240716_macfas6liftoff_hg38gencodev47_basic/outs/atac_fragments.tsv.gz"

STEP 2 create seurat object

# create a Seurat object containing the RNA adata
gc_liftoff_1MI5_SO <- CreateSeuratObject(
  counts = gc_liftoff_1MI5_matrix$`Gene Expression`,
  assay = "RNA"
)


# create ATAC assay and add it to the object
gc_liftoff_1MI5_SO[["ATAC"]] <- CreateChromatinAssay(
  counts = gc_liftoff_1MI5_matrix$Peaks,
  sep = c(":", "-"),
  fragments = gc_liftoff_1MI5_fragpath
)

STEP 3 add macfas6 gencodev47 liftoff gtf so TSS.enrichment score can be calculated
Mapped multiomics reads (fastq's) with 10x cellranger arc using the following fasta & gtf
input_fasta: ["mac_ref/GCA_011100615.1_Macaca_fascicularis_6.0_genomic.fna"]
input_gtf: ["mac_ref/macFas6-hg38-gencode.v47.basic.sorted.gtf"]. Made with liftoff software. More details here.

IMPORTANT: chromosomes in liftoff gtf aren't listed as 'chr1', 'chr2', 'chr3' in UCSC style or '1', '2', '3' in NCBI style. They are listed as genbank seq accession numbers 'CM021939.1' for chrom 1, 'CM021940.1' for chrom 2, 'CM021941.1' for chrom 3, etc (has chromosomes 1-20, chromosome X, then the rest are 'Un' chromosomes)

# add liftoff annotation to object
# Step 3a: Load the GTF file 
gencode_gtf_path <- '~/macaque_multiomics/mac_ref/macFas6-hg38-gencode.v47.basic.sorted.gtf'
gencode_gtf <- rtracklayer::import(gencode_gtf_path)

# Step 3b: Map gene_type to gene_biotype
# Check if gene_type exists, and then map it to gene_biotype
if ("gene_type" %in% colnames(mcols(gencode_gtf))) {
  mcols(gencode_gtf)$gene_biotype <- NA
  mcols(gencode_gtf)$gene_biotype[mcols(gencode_gtf)$gene_type == "protein_coding"] <- "protein_coding"
} else {
  stop("The GTF file does not contain a gene_type field.")
}

# did this because TSSenrichment function requires gene_biotype info. In liftoff gtf attribute listed as gene_type
# i.e gene_type "protein_coding", gene_type "lncRNA", etc


# Step 3c: Filter out entries with missing or invalid data (filtered out all NA's that were in the liftoff gtf GRanges object before calculating TSS score)
gencode_gtf <- gencode_gtf[
  !is.na(mcols(gencode_gtf)$gene_biotype) &
  !is.na(seqnames(gencode_gtf)) &
  !is.na(start(gencode_gtf)) &
  !is.na(end(gencode_gtf)) &
  !is.na(strand(gencode_gtf))
]

# Step 3d: Make default assay ATAC
DefaultAssay(gc_liftoff_1MI5_SO) <- "ATAC"

# Step 3e: Assign the gencode_gtf to the Seurat object
Annotation(gc_liftoff_1MI5_SO) <- gencode_gtf

# Step 3f: Run TSSEnrichment() function
gc_liftoff_1MI5_SO <- TSSEnrichment(gc_liftoff_1MI5_SO)

STEP 4 calculate nucleosome signal

gc_liftoff_1MI5_SO <- NucleosomeSignal(gc_liftoff_1MI5_SO)

STEP 5 Make QC violin plots

VlnPlot(
  object = gc_liftoff_1MI5_SO,
  features = c("nCount_RNA", "nCount_ATAC", "TSS.enrichment", "nucleosome_signal"),
  ncol = 4,
  pt.size = 0
)

STEP 6 make density scatter plot

DensityScatter(gc_liftoff_1MI5_SO, x = 'nCount_ATAC', y = 'TSS.enrichment', log_x = TRUE, quantiles = TRUE)

STEP 7 subset/filter based on tutorial cutoffs

# filter out low quality cells 
gc_liftoff_1MI5_SO <- subset(
  x = gc_liftoff_1MI5_SO,
  subset = nCount_ATAC < 100000 &
    nCount_RNA < 25000 &
    nCount_ATAC > 1800 &
    nCount_RNA > 1000 &
    nucleosome_signal < 2 &
    TSS.enrichment > 1
)

STEP 8 normalize the gene expression data using SCTransform, and reduce the dimensionality using PCA.

DefaultAssay(gc_liftoff_1MI5_SO) <- "RNA"
gc_liftoff_1MI5_SO <- SCTransform(gc_liftoff_1MI5_SO)
gc_liftoff_1MI5_SO <- RunPCA(gc_liftoff_1MI5_SO)

STEP 9 process the DNA accessibility assay the same way we would process a scATAC-seq dataset, by performing latent semantic indexing (LSI)

DefaultAssay(gc_liftoff_1MI5_SO) <- "ATAC"
gc_liftoff_1MI5_SO <- FindTopFeatures(gc_liftoff_1MI5_SO, min.cutoff = 5)
gc_liftoff_1MI5_SO <- RunTFIDF(gc_liftoff_1MI5_SO)
gc_liftoff_1MI5_SO <- RunSVD(gc_liftoff_1MI5_SO)

STEP 10 make snRNAseq, snATACseq, & snRNAseq + ATACseq UMAPs

# snRNAseq UMAP
gc_liftoff_1MI5_SO <- FindNeighbors(gc_liftoff_1MI5_SO, dims = 1:30)
gc_liftoff_1MI5_SO <- FindClusters(gc_liftoff_1MI5_SO, graph.name = "SCT_snn", resolution = 0.4)
gc_liftoff_1MI5_SO <- RunUMAP(gc_liftoff_1MI5_SO, dims = 1:30)
DimPlot(gc_liftoff_1MI5_SO, reduction = "umap", group.by = "SCT_snn_res.0.4", label = TRUE) + ggtitle("1MI5 snRNAseq res.0.4")

# snATACseq UMAP
gc_liftoff_1MI5_SO <- RunUMAP(gc_liftoff_1MI5_SO, reduction = 'lsi', dims = 2:30, reduction.name = "umap.atac", reduction.key = "atacUMAP_")
DimPlot(gc_liftoff_1MI5_SO, reduction = "umap.atac", label = TRUE, label.size = 2.5, repel = TRUE) + ggtitle("1MI5 snATAC res.0.4")


# snRNAseq + snATACseq UMAP
gc_liftoff_1MI5_SO <- FindMultiModalNeighbors(gc_liftoff_1MI5_SO, reduction.list = list("pca", "lsi"), dims.list = list(1:30, 2:30))
gc_liftoff_1MI5_SO <- RunUMAP(gc_liftoff_1MI5_SO, nn.name = "weighted.nn", reduction.name = "wnn.umap", reduction.key = "wnnUMAP_")
gc_liftoff_1MI5_SO <- FindClusters(gc_liftoff_1MI5_SO, graph.name = "wsnn", algorithm = 3, verbose = FALSE)
DimPlot(gc_liftoff_1MI5_SO, reduction = "wnn.umap", label = TRUE, label.size = 2.5, repel = TRUE) + ggtitle("1MI5 snRNA + snATAC res.0.4")

STEP 11 Linking peaks to genes (where error occurs)

DefaultAssay(gc_liftoff_1MI5_SO) <- "ATAC"

# first compute the GC content for each peak
gc_liftoff_1MI5_SO <- RegionStats(gc_liftoff_1MI5_SO, genome = BSgenome.Mfascicularis.NCBI.6.0)



# link peaks to genes
gc_liftoff_1MI5_SO <- LinkPeaks(
  object = gc_liftoff_1MI5_SO,
  peak.assay = "ATAC",
  expression.assay = "SCT",
  genes.use = c("LYZ", "MS4A1")
)

Error in density.default(x = query.feature[[featmatch]], kernel = "gaussian",  : 
  argument 'x' must be numeric

STEP 12 check sequence level style

seqlevelsStyle(BSgenome.Mfascicularis.NCBI.6.0)

[1] "NCBI"

STEP 13 check GC content metadata (still see NA's)

gc_md <- gc_liftoff_1MI5_SO[['ATAC']][[]]
head(gc_md)
gc_md[is.na(gc_md$GC.percent), ]

STEP 14 Print session info

devtools::session_info()
─ Session info ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.4.0 (2024-04-24)
 os       Ubuntu 24.04.1 LTS
 system   x86_64, linux-gnu
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       /UTC
 date     2025-02-06
 rstudio  2024.09.0+375 Cranberry Hibiscus (server)
 pandoc   3.2 @ /usr/lib/rstudio-server/bin/quarto/bin/tools/x86_64/ (via rmarkdown)

─ Packages ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package                         * version    date (UTC) lib source
 abind                             1.4-8      2024-09-12 [2] CRAN (R 4.4.0)
 AnnotationDbi                   * 1.66.0     2024-05-01 [1] Bioconductor 3.19 (R 4.4.0)
 Biobase                         * 2.64.0     2024-04-30 [1] Bioconductor 3.19 (R 4.4.0)
 BiocFileCache                     2.12.0     2024-04-30 [1] Bioconductor 3.19 (R 4.4.0)
 BiocGenerics                    * 0.50.0     2024-04-30 [1] Bioconductor 3.19 (R 4.4.0)
 BiocIO                          * 1.14.0     2024-04-30 [1] Bioconductor 3.19 (R 4.4.0)
 BiocManager                       1.30.25    2024-08-28 [2] CRAN (R 4.4.0)
 BiocParallel                      1.38.0     2024-04-30 [1] Bioconductor 3.19 (R 4.4.0)
 biomaRt                           2.60.1     2024-06-26 [1] Bioconductor 3.19 (R 4.4.0)
 Biostrings                      * 2.72.1     2024-06-02 [1] Bioconductor 3.19 (R 4.4.0)
 bit                               4.5.0      2024-09-20 [2] CRAN (R 4.4.0)
 bit64                             4.5.2      2024-09-22 [2] CRAN (R 4.4.0)
 bitops                            1.0-9      2024-10-03 [2] CRAN (R 4.4.0)
 blob                              1.2.4      2023-03-17 [2] CRAN (R 4.4.0)
 BSgenome                        * 1.72.0     2024-04-30 [1] Bioconductor 3.19 (R 4.4.0)
 BSgenome.Mfascicularis.NCBI.5.0 * 1.4.2      2024-11-21 [1] Bioconductor
 BSgenome.Mfascicularis.NCBI.6.0 * 1.5.0      2024-11-21 [1] Bioconductor
 cachem                            1.1.0      2024-05-16 [2] CRAN (R 4.4.0)
 cli                               3.6.3      2024-06-21 [2] CRAN (R 4.4.0)
 cluster                           2.1.6      2023-12-01 [5] CRAN (R 4.4.0)
 codetools                         0.2-20     2024-03-31 [5] CRAN (R 4.4.0)
 colorspace                        2.1-1      2024-07-26 [2] CRAN (R 4.4.0)
 cowplot                           1.1.3      2024-01-22 [2] CRAN (R 4.4.0)
 crayon                            1.5.3      2024-06-20 [2] CRAN (R 4.4.0)
 curl                              5.2.3      2024-09-20 [2] CRAN (R 4.4.0)
 data.table                        1.16.0     2024-08-27 [2] CRAN (R 4.4.0)
 DBI                               1.2.3      2024-06-02 [2] CRAN (R 4.4.0)
 dbplyr                            2.5.0      2024-03-19 [2] CRAN (R 4.4.0)
 DelayedArray                      0.30.1     2024-05-07 [1] Bioconductor 3.19 (R 4.4.0)
 deldir                            2.0-4      2024-02-28 [2] CRAN (R 4.4.0)
 devtools                        * 2.4.5      2022-10-11 [2] CRAN (R 4.4.0)
 digest                            0.6.37     2024-08-19 [2] CRAN (R 4.4.0)
 doParallel                      * 1.0.17     2022-02-07 [1] CRAN (R 4.4.0)
 dotCall64                         1.2        2024-10-04 [2] CRAN (R 4.4.0)
 DoubletFinder                   * 2.0.4      2024-12-05 [1] Github (chris-mcginnis-ucsf/DoubletFinder@03e9f37)
 dplyr                           * 1.1.4      2023-11-17 [2] CRAN (R 4.4.0)
 DropletQC                       * 0.0.0.9000 2024-12-01 [1] Github (powellgenomicslab/DropletQC@5d7dadc)
 ellipsis                          0.3.2      2021-04-29 [2] CRAN (R 4.4.0)
 evaluate                          1.0.0      2024-09-17 [2] CRAN (R 4.4.0)
 fansi                             1.0.6      2023-12-08 [2] CRAN (R 4.4.0)
 farver                            2.1.2      2024-05-13 [2] CRAN (R 4.4.0)
 fastDummies                       1.7.4      2024-08-16 [2] CRAN (R 4.4.0)
 fastmap                           1.2.0      2024-05-15 [2] CRAN (R 4.4.0)
 fastmatch                         1.1-4      2023-08-18 [1] CRAN (R 4.4.0)
 fields                          * 16.3       2024-09-30 [1] CRAN (R 4.4.0)
 filelock                          1.0.3      2023-12-11 [1] CRAN (R 4.4.0)
 fitdistrplus                      1.2-1      2024-07-12 [2] CRAN (R 4.4.0)
 flexmix                         * 2.3-19     2023-03-16 [2] CRAN (R 4.4.0)
 forcats                         * 1.0.0      2023-01-29 [2] CRAN (R 4.4.0)
 foreach                         * 1.5.2      2022-02-02 [2] CRAN (R 4.4.0)
 fs                                1.6.4      2024-04-25 [2] CRAN (R 4.4.0)
 future                          * 1.34.0     2024-07-29 [2] CRAN (R 4.4.0)
 future.apply                      1.11.2     2024-03-28 [2] CRAN (R 4.4.0)
 generics                          0.1.3      2022-07-05 [2] CRAN (R 4.4.0)
 GenomeInfoDb                    * 1.40.1     2024-05-24 [1] Bioconductor 3.19 (R 4.4.0)
 GenomeInfoDbData                  1.2.12     2024-10-01 [1] Bioconductor
 GenomicAlignments                 1.40.0     2024-04-30 [1] Bioconductor 3.19 (R 4.4.0)
 GenomicFeatures                 * 1.56.0     2024-04-30 [1] Bioconductor 3.19 (R 4.4.0)
 GenomicRanges                   * 1.56.2     2024-10-09 [1] Bioconductor 3.19 (R 4.4.0)
 ggplot2                         * 3.5.1      2024-04-23 [2] CRAN (R 4.4.0)
 ggrepel                           0.9.6      2024-09-07 [2] CRAN (R 4.4.0)
 ggridges                          0.5.6      2024-01-23 [2] CRAN (R 4.4.0)
 globals                           0.16.3     2024-03-08 [2] CRAN (R 4.4.0)
 glue                              1.8.0      2024-09-30 [2] CRAN (R 4.4.0)
 goftest                           1.2-3      2021-10-07 [2] CRAN (R 4.4.0)
 gridExtra                         2.3        2017-09-09 [2] CRAN (R 4.4.0)
 gtable                            0.3.5      2024-04-22 [2] CRAN (R 4.4.0)
 hdf5r                           * 1.3.11     2024-07-07 [2] CRAN (R 4.4.0)
 hms                               1.1.3      2023-03-21 [2] CRAN (R 4.4.0)
 htmltools                         0.5.8.1    2024-04-04 [2] CRAN (R 4.4.0)
 htmlwidgets                       1.6.4      2023-12-06 [2] CRAN (R 4.4.0)
 httpuv                            1.6.15     2024-03-26 [2] CRAN (R 4.4.0)
 httr                              1.4.7      2023-08-15 [2] CRAN (R 4.4.0)
 httr2                             1.0.5      2024-09-26 [2] CRAN (R 4.4.0)
 ica                               1.0-3      2022-07-08 [2] CRAN (R 4.4.0)
 igraph                            2.0.3      2024-03-13 [2] CRAN (R 4.4.0)
 IRanges                         * 2.38.1     2024-07-03 [1] Bioconductor 3.19 (R 4.4.0)
 irlba                             2.3.5.1    2022-10-03 [2] CRAN (R 4.4.0)
 iterators                       * 1.0.14     2022-02-05 [2] CRAN (R 4.4.0)
 jsonlite                          1.8.9      2024-09-20 [2] CRAN (R 4.4.0)
 KEGGREST                          1.44.1     2024-06-19 [1] Bioconductor 3.19 (R 4.4.0)
 KernSmooth                      * 2.23-24    2024-05-17 [5] CRAN (R 4.4.0)
 knitr                             1.48       2024-07-07 [2] CRAN (R 4.4.0)
 later                             1.3.2      2023-12-06 [2] CRAN (R 4.4.0)
 lattice                         * 0.22-5     2023-10-24 [5] CRAN (R 4.3.3)
 lazyeval                          0.2.2      2019-03-15 [2] CRAN (R 4.4.0)
 leiden                            0.4.3.1    2023-11-17 [2] CRAN (R 4.4.0)
 lifecycle                         1.0.4      2023-11-07 [2] CRAN (R 4.4.0)
 listenv                           0.9.1      2024-01-29 [2] CRAN (R 4.4.0)
 lmtest                            0.9-40     2022-03-21 [2] CRAN (R 4.4.0)
 lubridate                       * 1.9.3      2023-09-27 [2] CRAN (R 4.4.0)
 magrittr                          2.0.3      2022-03-30 [2] CRAN (R 4.4.0)
 maps                              3.4.2.1    2024-11-10 [1] CRAN (R 4.4.0)
 MASS                              7.3-61     2024-06-13 [2] CRAN (R 4.4.0)
 Matrix                            1.7-0      2024-04-26 [5] CRAN (R 4.4.0)
 MatrixGenerics                    1.16.0     2024-04-30 [1] Bioconductor 3.19 (R 4.4.0)
 matrixStats                       1.4.1      2024-09-08 [2] CRAN (R 4.4.0)
 mclust                            6.1.1      2024-04-29 [1] CRAN (R 4.4.0)
 memoise                           2.0.1      2021-11-26 [2] CRAN (R 4.4.0)
 mime                              0.12       2021-09-28 [2] CRAN (R 4.4.0)
 miniUI                            0.1.1.1    2018-05-18 [2] CRAN (R 4.4.0)
 miQC                            * 1.12.0     2024-04-30 [1] Bioconductor 3.19 (R 4.4.0)
 modeltools                        0.2-23     2020-03-05 [2] CRAN (R 4.4.0)
 munsell                           0.5.1      2024-04-01 [2] CRAN (R 4.4.0)
 nlme                              3.1-166    2024-08-14 [2] CRAN (R 4.4.0)
 nnet                              7.3-19     2023-05-03 [5] CRAN (R 4.3.3)
 parallelly                        1.38.0     2024-07-27 [2] CRAN (R 4.4.0)
 patchwork                       * 1.3.0      2024-09-16 [2] CRAN (R 4.4.0)
 pbapply                           1.7-2      2023-06-27 [2] CRAN (R 4.4.0)
 pillar                            1.9.0      2023-03-22 [2] CRAN (R 4.4.0)
 pkgbuild                          1.4.4      2024-03-17 [2] CRAN (R 4.4.0)
 pkgconfig                         2.0.3      2019-09-22 [2] CRAN (R 4.4.0)
 pkgload                           1.4.0      2024-06-28 [2] CRAN (R 4.4.0)
 plotly                            4.10.4     2024-01-13 [2] CRAN (R 4.4.0)
 plyr                              1.8.9      2023-10-02 [2] CRAN (R 4.4.0)
 png                               0.1-8      2022-11-29 [2] CRAN (R 4.4.0)
 polyclip                          1.10-7     2024-07-23 [2] CRAN (R 4.4.0)
 prettyunits                       1.2.0      2023-09-24 [2] CRAN (R 4.4.0)
 profvis                           0.4.0      2024-09-20 [2] CRAN (R 4.4.0)
 progress                          1.2.3      2023-12-06 [2] CRAN (R 4.4.0)
 progressr                         0.14.0     2023-08-10 [2] CRAN (R 4.4.0)
 promises                          1.3.0      2024-04-05 [2] CRAN (R 4.4.0)
 purrr                           * 1.0.2      2023-08-10 [2] CRAN (R 4.4.0)
 R.methodsS3                     * 1.8.2      2022-06-13 [1] CRAN (R 4.4.0)
 R.oo                            * 1.27.0     2024-11-01 [1] CRAN (R 4.4.0)
 R.utils                         * 2.12.3     2023-11-18 [1] CRAN (R 4.4.0)
 R6                                2.5.1      2021-08-19 [2] CRAN (R 4.4.0)
 RANN                              2.6.2      2024-08-25 [2] CRAN (R 4.4.0)
 rappdirs                          0.3.3      2021-01-31 [2] CRAN (R 4.4.0)
 RColorBrewer                      1.1-3      2022-04-03 [2] CRAN (R 4.4.0)
 Rcpp                              1.0.13     2024-07-17 [2] CRAN (R 4.4.0)
 RcppAnnoy                         0.0.22     2024-01-23 [2] CRAN (R 4.4.0)
 RcppHNSW                          0.6.0      2024-02-04 [2] CRAN (R 4.4.0)
 RcppRoll                          0.3.1      2024-07-07 [1] CRAN (R 4.4.0)
 RCurl                             1.98-1.16  2024-07-11 [1] CRAN (R 4.4.0)
 readr                           * 2.1.5      2024-01-10 [2] CRAN (R 4.4.0)
 remotes                         * 2.5.0      2024-03-17 [2] CRAN (R 4.4.0)
 reshape2                          1.4.4      2020-04-09 [2] CRAN (R 4.4.0)
 restfulr                          0.0.15     2022-06-16 [1] CRAN (R 4.4.0)
 reticulate                        1.39.0     2024-09-05 [2] CRAN (R 4.4.0)
 rjson                             0.2.23     2024-09-16 [1] CRAN (R 4.4.0)
 rlang                             1.1.4      2024-06-04 [2] CRAN (R 4.4.0)
 rmarkdown                         2.28       2024-08-17 [2] CRAN (R 4.4.0)
 ROCR                            * 1.0-11     2020-05-02 [2] CRAN (R 4.4.0)
 Rsamtools                         2.20.0     2024-04-30 [1] Bioconductor 3.19 (R 4.4.0)
 RSpectra                          0.16-2     2024-07-18 [2] CRAN (R 4.4.0)
 RSQLite                           2.3.8      2024-11-17 [1] CRAN (R 4.4.0)
 rstudioapi                        0.16.0     2024-03-24 [2] CRAN (R 4.4.0)
 rsvd                              1.0.5      2021-04-16 [1] CRAN (R 4.4.0)
 rtracklayer                     * 1.64.0     2024-04-30 [1] Bioconductor 3.19 (R 4.4.0)
 Rtsne                             0.17       2023-12-07 [2] CRAN (R 4.4.0)
 S4Arrays                          1.4.1      2024-05-20 [1] Bioconductor 3.19 (R 4.4.0)
 S4Vectors                       * 0.42.1     2024-07-03 [1] Bioconductor 3.19 (R 4.4.0)
 scales                            1.3.0      2023-11-28 [2] CRAN (R 4.4.0)
 scattermore                       1.2        2023-06-12 [2] CRAN (R 4.4.0)
 sctransform                       0.4.1      2023-10-19 [2] CRAN (R 4.4.0)
 sessioninfo                       1.2.2      2021-12-06 [2] CRAN (R 4.4.0)
 Seurat                          * 5.1.0      2024-05-10 [2] CRAN (R 4.4.0)
 SeuratDisk                      * 0.0.0.9021 2024-10-07 [1] Github (mojaveazure/seurat-disk@877d4e1)
 SeuratObject                    * 5.0.2      2024-05-08 [2] CRAN (R 4.4.0)
 SeuratWrappers                    0.4.0      2024-12-05 [1] Github (satijalab/seurat-wrappers@a1eb0d8)
 shiny                             1.9.1      2024-08-01 [2] CRAN (R 4.4.0)
 Signac                          * 1.14.9002  2025-01-17 [1] Github (stuart-lab/signac@39df167)
 SingleCellExperiment              1.26.0     2024-04-30 [1] Bioconductor 3.19 (R 4.4.0)
 SoupX                           * 1.6.2      2022-11-01 [2] CRAN (R 4.4.0)
 sp                              * 2.1-4      2024-04-30 [2] CRAN (R 4.4.0)
 spam                            * 2.11-0     2024-10-03 [2] CRAN (R 4.4.0)
 SparseArray                       1.4.8      2024-05-24 [1] Bioconductor 3.19 (R 4.4.0)
 spatstat.data                     3.1-2      2024-06-21 [2] CRAN (R 4.4.0)
 spatstat.explore                  3.3-2      2024-08-21 [2] CRAN (R 4.4.0)
 spatstat.geom                     3.3-3      2024-09-18 [2] CRAN (R 4.4.0)
 spatstat.random                   3.3-2      2024-09-18 [2] CRAN (R 4.4.0)
 spatstat.sparse                   3.1-0      2024-06-21 [2] CRAN (R 4.4.0)
 spatstat.univar                   3.0-1      2024-09-05 [2] CRAN (R 4.4.0)
 spatstat.utils                    3.1-0      2024-08-17 [2] CRAN (R 4.4.0)
 stringi                           1.8.4      2024-05-06 [2] CRAN (R 4.4.0)
 stringr                         * 1.5.1      2023-11-14 [2] CRAN (R 4.4.0)
 SummarizedExperiment              1.34.0     2024-05-01 [1] Bioconductor 3.19 (R 4.4.0)
 survival                          3.7-0      2024-06-05 [2] CRAN (R 4.4.0)
 tensor                            1.5        2012-05-05 [2] CRAN (R 4.4.0)
 tibble                          * 3.2.1      2023-03-20 [2] CRAN (R 4.4.0)
 tidyr                           * 1.3.1      2024-01-24 [2] CRAN (R 4.4.0)
 tidyselect                        1.2.1      2024-03-11 [2] CRAN (R 4.4.0)
 tidyverse                       * 2.0.0      2023-02-22 [2] CRAN (R 4.4.0)
 timechange                        0.3.0      2024-01-18 [2] CRAN (R 4.4.0)
 txdbmaker                       * 1.0.1      2024-06-23 [1] Bioconductor 3.19 (R 4.4.0)
 tzdb                              0.4.0      2023-05-12 [2] CRAN (R 4.4.0)
 UCSC.utils                        1.0.0      2024-04-30 [1] Bioconductor 3.19 (R 4.4.0)
 urlchecker                        1.0.1      2021-11-30 [2] CRAN (R 4.4.0)
 usethis                         * 3.0.0      2024-07-29 [2] CRAN (R 4.4.0)
 utf8                              1.2.4      2023-10-22 [2] CRAN (R 4.4.0)
 uwot                              0.2.2      2024-04-21 [2] CRAN (R 4.4.0)
 vctrs                             0.6.5      2023-12-01 [2] CRAN (R 4.4.0)
 viridisLite                     * 0.4.2      2023-05-02 [2] CRAN (R 4.4.0)
 withr                             3.0.1      2024-07-31 [2] CRAN (R 4.4.0)
 xfun                              0.48       2024-10-03 [2] CRAN (R 4.4.0)
 XML                               3.99-0.17  2024-06-25 [1] CRAN (R 4.4.0)
 xml2                              1.3.6      2023-12-04 [2] CRAN (R 4.4.0)
 xtable                            1.8-4      2019-04-21 [2] CRAN (R 4.4.0)
 XVector                         * 0.44.0     2024-04-30 [1] Bioconductor 3.19 (R 4.4.0)
 yaml                              2.3.10     2024-07-26 [2] CRAN (R 4.4.0)
 zlibbioc                          1.50.0     2024-04-30 [1] Bioconductor 3.19 (R 4.4.0)
 zoo                               1.8-12     2023-04-13 [2] CRAN (R 4.4.0)

 [1] ~/R/x86_64-pc-linux-gnu-library/4.4
 [2] /library
 [3] /usr/local/lib/R/site-library
 [4] /usr/lib/R/site-library
 [5] /usr/lib/R/library

@zgb963
Copy link
Author

zgb963 commented Feb 14, 2025

Hi @timoast I tried changing the chromosome names in BSgenome.Mfascicularis.NCBI.6.0 (has NCBI naming style of chromosomes "1", "2", "3", etc) to match the ones that are in the GTF (chromosomes listed as genbank accession numbers 'CM021939.1' for chrom 1, 'CM021940.1' for chrom 2, 'CM021941.1' for chrom 3, etc) that I added to the seurat object gc_liftoff_1MI5_SO in STEP 3 above. I only wanted to change chromosomes 1-20 & X. I changed chromosome names in the BS genome object but it unfortunately removed all the other metadata including sequence lengths. I'm unable to recover it when I reload the BSgenome.Mfascicularis.NCBI.6.0 or when I try to add them manually I'm unable too. More information on that is here. I instead read in an indexed fasta file instead of using a BS genome object for running RegionStats() & then after tried running LinkPeaks().

genome parameter for RegionStats()
A BSgenome object or any other object supported by getSeq. Do showMethods("getSeq") to get the list of all supported object types.

showMethods("getSeq")
# Function: getSeq (package Biostrings)
# x="BSgenome"
# x="FaFile"
# x="FaFileList"
# x="TwoBitFile"
# x="XStringSet"

So I read in my indexed fasta file, and the chromosome names match exactly with the GTF in STEP 3 above. I still got an error for linking peaks to genes

DefaultAssay(gc_liftoff_1MI5_SO) <- "ATAC"


macfas6_fasta_path <- "~/macaque_multiomics/mac_ref/GCA_011100615.1_Macaca_fascicularis_6.0_genomic.fna"
macfas6_fasta_file <- FaFile(macfas6_fasta_path)  # Create FaFile object


# first compute the GC content for each peak (works, no warnings or errors)
gc_liftoff_1MI5_SO <- RegionStats(gc_liftoff_1MI5_SO, genome = macfas6_fasta_file)



# link peaks to genes
gc_liftoff_1MI5_SO <- LinkPeaks(
  object = gc_liftoff_1MI5_SO,
  peak.assay = "ATAC",
  expression.assay = "SCT",
  genes.use = c("LYZ", "MS4A1")
)

Testing 2 genes and 206443 peaks
  |                                                  | 0 % ~calculating  Warning: Requested more features than present in supplied data.
            Returning 0 featuresError in density.default(x = query.feature[[featmatch]], kernel = "gaussian",  : 
  argument 'x' must be numeric

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants