Open alipirani88 opened 1 week ago
Also, I dont find any documentation for createGiottoVisiumHDObject function. Is this a typo in https://drieslab.github.io/Giotto_website/articles/VisiumHD_Human_Colorectal_Cancer.html
@iqraAmin have you seen this before?
I am also trying createGiottoVisiumObject but no luck. I get an error:
N_pros <- createGiottoVisiumObject(
+ visium_dir = "/Volumes/home/neuro_rsrch/apirani/10X_Visium_HD_data/2024-07-23_H5_First_Batch/238687-HD01_275405-6-2/binned_outputs/square_002um",
+ expr_data = "raw",
+ png_name = "tissue_lowres_image.png",
+ gene_column_index = 2,
+ instructions = instrs)
A structured visium directory will be used
Error in data.table::fread(tissue_positions_path) :
input= must be a single character string containing a file name, a system command containing at least one space, a URL starting 'http[s]://', 'ftp[s]://' or 'file://', or, the input data itself containing at least one \n or \r
@iqraAmin have you seen this before?
I haven't come across an error like that before. The recent changes to the visiumHD functions haven't been merged into the suite branch yet; the latest version can be found in the suite_dev branch.
@alipirani88, could you provide me with the session info and a subset of your data so I can try to reproduce the error?
I am not sure how to subset the data with Giotto since I cannot generate a giotto object. I can subset it with Seurat if that would work or else if there is a better way to subset and share it - let me know.
FYI - I am able to manually create giotto object and generate an expression matrix using this code:
library(Giotto)
library(ComplexHeatmap)
setwd("/Users/apirani/Documents/Data_projects/10X_Visium_HD_data/2024-07-23_H5_First_Batch/238687-HD01_275405-6-2/binned_outputs")
save_dir <- "/Users/apirani/Documents/Data_projects/10X_Visium_HD_data_analysis/2024_10_15_Spatial_Giotto_analysis/2024_10_15_Primary_275405/plots"
dir.create(save_dir, recursive = TRUE)
data_path <- "/Users/apirani/Documents/Data_projects/10X_Visium_HD_data/2024-07-23_H5_First_Batch/238687-HD01_275405-6-2/binned_outputs"
expression_path <- file.path(data_path, 'square_002um/filtered_feature_bc_matrix')
expr_results <- get10Xmatrix(path_to_data = expression_path,
gene_column_index = 2)
tissue_positions_path <- file.path(data_path, 'square_002um/spatial/tissue_positions.parquet')
tissue_positions <- data.table::as.data.table(arrow::read_parquet(tissue_positions_path))
# convert expression matrix to minimal data.frame or data.table object
matrix_tile_dt <- data.table::as.data.table(Matrix::summary(expr_results))
genes <- expr_results@Dimnames[[1]]
samples <- expr_results@Dimnames[[2]]
matrix_tile_dt[, gene := genes[i]]
matrix_tile_dt[, pixel := samples[j]]
expr_pos_data <- data.table::merge.data.table(matrix_tile_dt,
tissue_positions,
by.x = 'pixel',
by.y = 'barcode')
expr_pos_data <- expr_pos_data[,.(pixel, pxl_row_in_fullres, pxl_col_in_fullres, gene, x)]
colnames(expr_pos_data) = c('pixel', 'x', 'y', 'gene', 'count')
giotto_points = createGiottoPoints(x = expr_pos_data[,.(x, y, gene, pixel, count)])
hexbin400 <- tessellate(extent = ext(giotto_points),
shape = 'hexagon',
shape_size = 400,
name = 'hex400')
plot(hexbin400)
instrs = createGiottoInstructions(
save_dir = save_dir,
save_plot = TRUE,
show_plot = FALSE,
return_plot = FALSE
)
# gpoints provides spatial gene expression information
# gpolygons provides spatial unit information (here = hexagon tiles)
visiumHD = createGiottoObjectSubcellular(gpoints = list('rna' = giotto_points),
gpolygons = list('hex400' = hexbin400),
instructions = instrs)
# create spatial centroids for each spatial unit (hexagon)
visiumHD = addSpatialCentroidLocations(gobject = visiumHD,
poly_info = 'hex400')
Is there a way to create Giotto visium object using the above code instead of createGiottoObjectSubcellular?
Downstream I would like to merge two objects from treated vs non-treated groups to perform integration analysis.
@alipirani88, could you share which Giotto version you’re using? The createGiottoVisiumHDObject() function is available in the newer Giotto version (4.1.3) on the suite_dev branch.
Sure - Here is my session information
R version 4.4.1 (2024-06-14)
Platform: aarch64-apple-darwin20
Running under: macOS Sonoma 14.7
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: America/Chicago
tzcode source: internal
attached base packages:
[1] grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] ComplexHeatmap_2.20.0 Giotto_4.1.0 GiottoClass_0.3.5
loaded via a namespace (and not attached):
[1] colorRamp2_0.1.0 deldir_2.0-4 rlang_1.1.4 magrittr_2.0.3 clue_0.3-65 GetoptLong_1.0.5 GiottoUtils_0.1.12 matrixStats_1.4.1
[9] compiler_4.4.1 png_0.1-8 systemfonts_1.1.0 vctrs_0.6.5 reshape2_1.4.4 stringr_1.5.1 pkgconfig_2.0.3 shape_1.4.6.1
[17] crayon_1.5.3 fastmap_1.2.0 XVector_0.44.0 backports_1.5.0 magick_2.8.5 labeling_0.4.3 utf8_1.2.4 rmarkdown_2.28
[25] ragg_1.3.3 purrr_1.0.2 bit_4.5.0 xfun_0.48 beachmat_2.20.0 zlibbioc_1.50.0 cachem_1.1.0 jsonlite_1.8.9
[33] DelayedArray_0.30.1 BiocParallel_1.38.0 terra_1.7-78 irlba_2.3.5.1 parallel_4.4.1 cluster_2.1.6 R6_2.5.1 bslib_0.8.0
[41] stringi_1.8.4 RColorBrewer_1.1-3 reticulate_1.39.0 parallelly_1.38.0 jquerylib_0.1.4 scattermore_1.2 Rcpp_1.0.13 assertthat_0.2.1
[49] iterators_1.0.14 knitr_1.48 future.apply_1.11.2 R.utils_2.12.3 FNN_1.1.4.1 IRanges_2.38.1 Matrix_1.7-0 igraph_2.0.3
[57] tidyselect_1.2.1 abind_1.4-8 rstudioapi_0.16.0 yaml_2.3.10 doParallel_1.0.17 codetools_0.2-20 listenv_0.9.1 lattice_0.22-6
[65] tibble_3.2.1 plyr_1.8.9 withr_3.0.1 evaluate_1.0.0 future_1.34.0 circlize_0.4.16 pillar_1.9.0 MatrixGenerics_1.16.0
[73] checkmate_2.3.2 foreach_1.5.2 stats4_4.4.1 plotly_4.10.4 generics_0.1.3 dbscan_1.2-0 sp_2.1-4 S4Vectors_0.42.1
[81] ggplot2_3.5.1 munsell_0.5.1 scales_1.3.0 globals_0.16.3 gtools_3.9.5 glue_1.8.0 lazyeval_0.2.2 tools_4.4.1
[89] GiottoVisuals_0.2.4 data.table_1.16.0 ScaledMatrix_1.12.0 cowplot_1.1.3 tidyr_1.3.1 colorspace_2.1-1 BiocSingular_1.20.0 rsvd_1.0.5
[97] cli_3.6.3 textshaping_0.4.0 fansi_1.0.6 S4Arrays_1.4.1 viridisLite_0.4.2 arrow_17.0.0.1 dplyr_1.1.4 uwot_0.2.2
[105] gtable_0.3.5 R.methodsS3_1.8.2 sass_0.4.9 digest_0.6.37 BiocGenerics_0.50.0 SparseArray_1.4.8 ggrepel_0.9.6 farver_2.1.2
[113] rjson_0.2.23 htmlwidgets_1.6.4 htmltools_0.5.8.1 R.oo_1.26.0 lifecycle_1.0.4 httr_1.4.7 GlobalOptions_0.1.2 bit64_4.5.2
I tried installing the suite_dev branch (devtools::install_github("drieslab/Giotto@suite_dev")) but I get this error:
Installing package into ‘/Users/apirani/Library/R/arm64/4.4/library’
(as ‘lib’ is unspecified)
ERROR: dependencies ‘GiottoClass’, ‘GiottoUtils’, ‘GiottoVisuals’ are not available for package ‘Giotto’
* removing ‘/Users/apirani/Library/R/arm64/4.4/library/Giotto’
Warning messages:
1: packages ‘GiottoVisuals’, ‘GiottoUtils’, ‘GiottoClass’ are not available for this version of R
Versions of these packages for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
2: In i.p(...) :
installation of package ‘/var/folders/3w/d12xrph92qzffw5mw2y34kk80000gq/T//RtmpjSh84N/file867f2aa18e6b/Giotto_4.1.3.tar.gz’ had non-zero exit status
@alipirani88, could you try installing GiottoVisuals@dev, GiottoUtils@dev, and GiottoClass@dev first? Once those are installed, please proceed with the Giotto@suite_dev installation. Hopefully, this will resolve the issue.
Hi,
Any idea what does this error mean?
visiumHD_object <- visiumHD$create_gobject(visiumHD_dir = "/Users/apirani/Documents/Data_projects/10X_Visium_HD_data/2024-07-23_H5_First_Batch/238687-HD01_275405-6-2/binned_outputs/square_002um", expr_data = "raw", gene_column_index = 2, png_name = "tissue_lowres_image.png")
Error:
python already initialized in this session active environment : 'giotto_env' python version : 3.10 a giotto python environment was found Using python path: "/Users/apirani/Library/r-miniconda-arm64/envs/giotto_env/bin/pythonw" loading expression matrix ... loading tissue positions file ... creating visiumHD tissue position x expression data file ... Selecting col "gene" as feat_ID column Selecting cols "x" and "y" as x and y respectively Setting feature info [rna] loading expression matrix ... loading tissue positions file ... creating visiumHD tissue position x expression data file ... subsetting visiumHD on array rows subsetting visiumHD on array columns subsetting visiumHD on expression matrix Selecting col "gene" as feat_ID column Selecting cols "x" and "y" as x and y respectively Error in seq.default(x_start, e[["xmax"]] - (0.5 * ccd), by = ccd) : wrong sign in 'by' argument