Figure 3 Dip-C highlights the geomeTriD package,
illustrating its ability to visualize 3D models derived from Dip-C, along with
multiple genomic signals mapped onto single-cell 3D structures.
library(geomeTriD)
library(geomeTriD.documentation)
library(GenomicRanges)
library(TxDb.Hsapiens.UCSC.hg38.knownGene)
library(org.Hs.eg.db)
library(colorRamps)This data were downloaded from GEO with accession GSE117874. We will first present the GM12878 cell 3 with all chromosomes.
## set supperloop positions
supperloops <- GRanges(c('Xa:56800000-56850000',
'Xa:75350000-75400000',
'Xa:115000000-115050000',
'Xa:130850000-130900000',
'Xb:56800000-56850000',
'Xb:75350000-75400000',
'Xb:115000000-115050000',
'Xb:130850000-130900000'))
names(supperloops) <- c('ICCE', 'x75', 'DXZ4', 'FIRRE',
'ICCE', 'x75', 'DXZ4', 'FIRRE')
supperloops$label <- names(supperloops)
supperloops$col <- c(2:5, 2:5) ## set colors for each element
supperloops$type <- 'gene' ## set it as gene
## set the data folder, all data are available in the extdata folder of this package
extdata <- system.file('extdata', 'GSE117874', package='geomeTriD.documentation')
hickit_3dg <- dir(extdata, '3dg', full.names = TRUE)
## load the data
hickit <- import3dg(hickit_3dg, parental_postfix=NULL)[[1]]
## subset sample chromosome information to avoid the tool overload
hickit <- hickit[seq_along(hickit) %in%
sample.int(length(hickit), size = 5000) |
seqnames(hickit) %in% c('Xa', 'Xb')]
## set colors to emphersize the Xa and Xb
col.backbone <- gray.colors(n = length(seqlevels(hickit)))
names(col.backbone) <- seqlevels(hickit)
col.backbone['Xa'] <- 'brown'
col.backbone['Xb'] <- 'orange'
cell3 <- view3dStructure(hickit, feature.gr = supperloops,
renderer = 'none', resolution=1,
col.backbone = col.backbone, lwd.backbone = 0.25)
backbone <- extractBackbonePositions(cell3, names(cell3)[grepl('backbone', names(cell3))])
supperloop_spheres <- createTADGeometries(supperloops, backbone, alpha = 0.8)## Warning in createTADGeometries(supperloops, backbone, alpha = 0.8): input tad
## has duplicated label. Please keep it unique.
threeJsViewer(cell3, supperloop_spheres)We will then present the four supperloop anchors in chrX of GM12878 cell with segment and sphere style.
hickit <- import3dg(hickit_3dg, parental_postfix=c('a', 'b'))[[1]]
## split it into maternal and paternal 3D structures.
hickit.a <- hickit[hickit$parental=='a'] ## mat
hickit.b <- hickit[hickit$parental=='b'] ## pat
## delete the parental information
hickit.a$parental <- hickit.b$parental <- NULL
## set data range
range <- GRanges('X:1-155270560')
## prepare the coordinates for the four superloops.
supperloops <- GRanges(c('X:56800000-56850000',
'X:75350000-75400000',
'X:115000000-115050000',
'X:130850000-130900000'))
names(supperloops) <- c('ICCE', 'x75', 'DXZ4', 'FIRRE')
supperloops$label <- names(supperloops)
supperloops$col <- 2:5 ## set colors for each element
supperloops$type <- 'gene' ## set it as gene
## subset the data by given range
hickit.a <- subsetByOverlaps(hickit.a, range)
hickit.b <- subsetByOverlaps(hickit.b, range)
hickit.a <- alignCoor(hickit.a, hickit.b)
## prepare the backbone colors
resolution <- 3
backbone_colors <- matlab.like2(n=resolution*length(hickit.a))
## add the superloops as segments
c1 <- view3dStructure(hickit.a,
feature.gr=supperloops,
renderer = 'none',
region = range,
resolution=resolution,
show_coor=FALSE,
lwd.backbone = 0.25,
col.backbone = backbone_colors,
lwd.gene=6)
c2 <- view3dStructure(hickit.b,
feature.gr=supperloops,
renderer = 'none',
region = range,
resolution=resolution,
show_coor=FALSE,
lwd.backbone = 0.25,
col.backbone = backbone_colors,
lwd.gene=6)
c2 <- lapply(c2, function(.ele) { ## put pat to right pannel
.ele$side = 'right'
.ele
})
## view the data
threeJsViewer(c1, c2, title = c('GM12878 cell 3 mat', 'GM12878 cell 3 pat'))
#widget <-threeJsViewer(c1, c2, title = c('mat', 'pat'))
#tempfile <- 'Fig4.html'
#htmlwidgets::saveWidget(widget, file=tempfile)
#utils::browseURL(tempfile)
## view the superloops as spheres
addFeaturesAsSphere <- function(obj, features, ...){
backbone <- extractBackbonePositions(obj)
spheres <- createTADGeometries(features, backbone, ...)
c(obj, spheres)
}
mat <- view3dStructure(hickit.a, renderer = 'none', region = range,
resolution=resolution, show_coor=FALSE,
lwd.backbone = 0.25,
col.backbone = backbone_colors)
mat <- addFeaturesAsSphere(mat, supperloops, alpha = 0.5)
pat <- view3dStructure(hickit.b, renderer = 'none', region = range,
resolution=resolution, show_coor=FALSE,
lwd.backbone = 0.25,
col.backbone = backbone_colors)
mat <- addFeaturesAsSphere(mat, supperloops, alpha = 0.5)
pat <- addFeaturesAsSphere(pat, supperloops, alpha = 0.5)
showPairs(mat, pat, title = c('GM12878 cell 3 mat', 'GM12878 cell 3 pat'))
## load the processed data.
hickit.a <- readRDS(file.path(extdata, 'hickit.a.rds'))
hickit.b <- readRDS(file.path(extdata, 'hickit.b.rds'))
widgets <- mapply(function(a, b, i){
mat <- view3dStructure(a, renderer = 'none', region = range,
resolution=resolution, show_coor=FALSE, lwd.backbone = 0.25,
col.backbone = backbone_colors)
mat <- addFeaturesAsSphere(mat, supperloops, alpha = 0.5)
pat <- view3dStructure(b, renderer = 'none', region = range,
resolution=resolution, show_coor=FALSE, lwd.backbone = 0.25,
col.backbone = backbone_colors)
pat <- addFeaturesAsSphere(pat, supperloops, alpha = 0.5)
showPairs(mat, pat, title = paste('cell', i, c('mat', 'pat')),
background = c("#11111188",
"#222222DD",
"#222222DD",
"#11111188"))
}, hickit.a, hickit.b, names(hickit.a), SIMPLIFY = FALSE)
widgets[[1]]
widgets[[8]]## R version 4.5.2 (2025-10-31)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.3 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
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## time zone: Etc/UTC
## tzcode source: system (glibc)
##
## attached base packages:
## [1] grid stats4 stats graphics grDevices utils datasets
## [8] methods base
##
## other attached packages:
## [1] colorRamps_2.3.4
## [2] org.Hs.eg.db_3.22.0
## [3] TxDb.Hsapiens.UCSC.hg38.knownGene_3.22.0
## [4] GenomicFeatures_1.62.0
## [5] AnnotationDbi_1.72.0
## [6] Biobase_2.70.0
## [7] GenomicRanges_1.62.0
## [8] Seqinfo_1.0.0
## [9] IRanges_2.44.0
## [10] S4Vectors_0.48.0
## [11] BiocGenerics_0.56.0
## [12] generics_0.1.4
## [13] geomeTriD.documentation_0.0.6
## [14] geomeTriD_1.5.0
##
## loaded via a namespace (and not attached):
## [1] strawr_0.0.92 RColorBrewer_1.1-3
## [3] rstudioapi_0.17.1 jsonlite_2.0.0
## [5] magrittr_2.0.4 farver_2.1.2
## [7] rmarkdown_2.30 fs_1.6.6
## [9] BiocIO_1.20.0 ragg_1.5.0
## [11] vctrs_0.6.5 memoise_2.0.1
## [13] Rsamtools_2.26.0 RCurl_1.98-1.17
## [15] base64enc_0.1-3 htmltools_0.5.8.1
## [17] S4Arrays_1.10.0 progress_1.2.3
## [19] plotrix_3.8-4 curl_7.0.0
## [21] Rhdf5lib_1.32.0 rhdf5_2.54.0
## [23] SparseArray_1.10.1 Formula_1.2-5
## [25] sass_0.4.10 parallelly_1.45.1
## [27] bslib_0.9.0 htmlwidgets_1.6.4
## [29] desc_1.4.3 Gviz_1.54.0
## [31] httr2_1.2.1 cachem_1.1.0
## [33] GenomicAlignments_1.46.0 igraph_2.2.1
## [35] lifecycle_1.0.4 pkgconfig_2.0.3
## [37] Matrix_1.7-4 R6_2.6.1
## [39] fastmap_1.2.0 MatrixGenerics_1.22.0
## [41] future_1.67.0 aricode_1.0.3
## [43] clue_0.3-66 digest_0.6.38
## [45] colorspace_2.1-2 textshaping_1.0.4
## [47] Hmisc_5.2-4 RSQLite_2.4.4
## [49] filelock_1.0.3 progressr_0.18.0
## [51] httr_1.4.7 abind_1.4-8
## [53] compiler_4.5.2 bit64_4.6.0-1
## [55] backports_1.5.0 htmlTable_2.4.3
## [57] S7_0.2.0 BiocParallel_1.44.0
## [59] DBI_1.2.3 R.utils_2.13.0
## [61] biomaRt_2.66.0 MASS_7.3-65
## [63] rappdirs_0.3.3 DelayedArray_0.36.0
## [65] rjson_0.2.23 tools_4.5.2
## [67] foreign_0.8-90 future.apply_1.20.0
## [69] nnet_7.3-20 R.oo_1.27.1
## [71] glue_1.8.0 restfulr_0.0.16
## [73] dbscan_1.2.3 InteractionSet_1.38.0
## [75] rhdf5filters_1.22.0 checkmate_2.3.3
## [77] cluster_2.1.8.1 gtable_0.3.6
## [79] BSgenome_1.78.0 trackViewer_1.47.0
## [81] R.methodsS3_1.8.2 ensembldb_2.34.0
## [83] data.table_1.17.8 hms_1.1.4
## [85] XVector_0.50.0 RANN_2.6.2
## [87] pillar_1.11.1 stringr_1.6.0
## [89] dplyr_1.1.4 BiocFileCache_3.0.0
## [91] lattice_0.22-7 deldir_2.0-4
## [93] rtracklayer_1.70.0 bit_4.6.0
## [95] biovizBase_1.58.0 tidyselect_1.2.1
## [97] Biostrings_2.78.0 knitr_1.50
## [99] gridExtra_2.3 ProtGenerics_1.42.0
## [101] SummarizedExperiment_1.40.0 xfun_0.54
## [103] matrixStats_1.5.0 stringi_1.8.7
## [105] UCSC.utils_1.6.0 lazyeval_0.2.2
## [107] yaml_2.3.10 evaluate_1.0.5
## [109] codetools_0.2-20 cigarillo_1.0.0
## [111] interp_1.1-6 tibble_3.3.0
## [113] cli_3.6.5 rpart_4.1.24
## [115] systemfonts_1.3.1 jquerylib_0.1.4
## [117] dichromat_2.0-0.1 Rcpp_1.1.0
## [119] GenomeInfoDb_1.46.0 globals_0.18.0
## [121] grImport_0.9-7 dbplyr_2.5.1
## [123] png_0.1-8 XML_3.99-0.20
## [125] parallel_4.5.2 pkgdown_2.2.0
## [127] rgl_1.3.24 ggplot2_4.0.0
## [129] blob_1.2.4 prettyunits_1.2.0
## [131] jpeg_0.1-11 latticeExtra_0.6-31
## [133] AnnotationFilter_1.34.0 bitops_1.0-9
## [135] txdbmaker_1.6.0 listenv_0.10.0
## [137] VariantAnnotation_1.56.0 scales_1.4.0
## [139] crayon_1.5.3 rlang_1.1.6
## [141] KEGGREST_1.50.0