omnideconv / spacedeconv Goto Github PK
View Code? Open in Web Editor NEWA unified interface to spatial transcriptomics deconvolution tools
Home Page: https://omnideconv.org/spacedeconv/
License: GNU General Public License v3.0
A unified interface to spatial transcriptomics deconvolution tools
Home Page: https://omnideconv.org/spacedeconv/
License: GNU General Public License v3.0
Add a module to print stats and info/computation time after deconvolution.
Just wondering, immunedeconv and omnideconv both have lower case names. Should we rename SpaceDeconv to spacedeconv?
Could you please add a qualitative palette to the plot_most_abundant function and maybe also RColorBrewerPalettes?
Thanks :)
Right now users have to specify the type of data (discrete, etc.). We can probably extract this information from the colData Dataframe directly and remove the paramter.
What would be a reasonable License? Omnideconv uses GPL-3.0 and Immunedeconv has a custom one. @FFinotello @mlist @grst
We should output some dataset statistics before starting a deconvolution/siganture building.
Useful information:
Potentially:
Should format this as a nice console output
When installing with pak::pkg_install("omnideconv/spacedeconv", dependencies = T) ,the installation of cell2location is canceled because of conflicting dependencies. When I installed cell2location manually,the proper environment of cell2location installation can not match the spacedeconv environment.
ERROR: Cannot install cell2location because these package versions have conflicting dependencies.
The conflict is caused by:
scvi-tools 0.20.3 depends on jaxlib>=0.4.3
scvi-tools 0.20.2 depends on jaxlib>=0.4.3
scvi-tools 0.20.1 depends on jaxlib>=0.4.3
scvi-tools 0.20.0 depends on jaxlib
scvi-tools 0.19.0 depends on jaxlib
scvi-tools 0.18.0 depends on jaxlib
scvi-tools 0.17.4 depends on jaxlib
scvi-tools 0.17.3 depends on jaxlib
scvi-tools 0.17.2 depends on jaxlib
scvi-tools 0.17.1 depends on jaxlib
scvi-tools 0.17.0 depends on jaxlib
To fix this you could try to:
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
In some cases we extract the deconvolution method from the method_celltype token. This fails for methods containing an "_". We should introduce a utility function "extract_method" which handles all those cases and returns correct method names.
SpaceDeconv will provide a unified interface to methods for deconvolution spatial transcriptomics (ST) data:
For point 3, a literature review is needed, but this could be a starting point:
Add parameter for custom metacell size (metacell has this parameter, stating the UMI count).
The plotting function with hexagons works with a correctly rotated spatial image. Older SpaceRanger Versions (<V2.0) may have differently rotated images (+-90 degrees). Since the angle of the spots is rotated by 30 degrees then the hexagons appear to be rotated too and don't touch as intended.
Introduce a "offset_rotation" parameter to fix the hexagon rotation in this case. Default should be the standard case (spatial image has hourglass on top left)
Update Plotting function to support fully custom plot titles, without adding _smoothed!
Add clustering for spots (and potentially for genes) and add this as an annotation to the spatial object. Related to #41
Please briefly describe your problem and what output you expect. If you have a question, please don't use this form.
Instead, ask on our Community Forum
Please include a minimal reproducible example (AKA a reprex). If you've never heard of a reprex before, start by reading https://www.tidyverse.org/help/#reprex.
I have installed all the dependencies, i receive this error when I install it from pak, i think it doesnt support UBUNTU OS?
# insert reprex here
```pak::pkg_install("omnideconv/spacedeconv", dependencies=TRUE)
! Using bundled GitHub PAT. Please add your own PAT using `gitcreds::gitcreds_set()`.
✔ Loading metadata database ... done
→ Will install 18 packages.
→ All 18 packages (9.65 MB) are cached.
+ CARD 1.1 [bld][cmp] (GitHub: 2d64b91)
+ ComICS 1.0.4 [bld]
+ concaveman 1.1.0 [bld] + ✔ libgdal-dev, ✔ gdal-bin, ✔ libgeos-dev, ✔ libproj-dev
+ ConsensusTME 0.0.1.9000 [bld][cmp] (GitHub: b3c8d3a)
+ Giotto 4.0.2 [bld][cmp] (GitHub: 7b8ad7b)
+ GiottoClass 0.1.3 [bld][cmp] (GitHub: fca6eb3)
+ GiottoVisuals 0.1.4 [bld][cmp] (GitHub: e3feee4)
+ glmnet 4.1-8 [bld][cmp]
+ immunedeconv 2.1.0 [bld][cmp] (GitHub: 12196fb)
+ MCMCpack 1.7-0 [bld][cmp]
+ metafor 4.4-0 [bld]
+ MuSiC 0.3.0 [bld][cmp] (GitHub: 7b18b03)
+ omnideconv 0.0.0.9000 [bld][cmp] (GitHub: 29322c9)
+ RcppML 0.3.7 [bld][cmp]
+ singscore 1.14.0 [bld]
+ spacedeconv 0.0.1.0000 [bld][cmp] (GitHub: cd33d4e)
+ spacexr 2.2.1 [bld][cmp] (GitHub: 90cc7dc)
+ V8 4.4.1 [bld][cmp] + ✔ libnode-dev
✔ All system requirements are already installed.
ℹ No downloads are needed, 18 pkgs (9.65 MB) are cached
ℹ Building spacedeconv 0.0.1.0000
ℹ Building omnideconv 0.0.0.9000
ℹ Building metafor 4.4-0
ℹ Building MCMCpack 1.7-0
ℹ Building RcppML 0.3.7
ℹ Building V8 4.4.1
ℹ Building glmnet 4.1-8
ℹ Building GiottoClass 0.1.3
ℹ Building singscore 1.14.0
✖ Failed to build spacedeconv 0.0.1.0000
Error:
! error in pak subprocess
Caused by error in `stop_task_build(state, worker)`:
! Failed to build source package spacedeconv.
Type .Last.error to see the more details.
> .Last.error
<callr_error/rlib_error_3_0/rlib_error/error>
Error:
! error in pak subprocess
Caused by error in `stop_task_build(state, worker)`:
! Failed to build source package spacedeconv.
---
Backtrace:
1. pak::pkg_install("omnideconv/spacedeconv", dependencies = TRUE)
2. pak:::remote(function(...) get("pkg_install_do_plan", asNamespace("pak"))(...), …
3. err$throw(res$error)
---
Subprocess backtrace:
1. base::withCallingHandlers(cli_message = function(msg) { …
2. get("pkg_install_do_plan", asNamespace("pak"))(...)
3. proposal$install()
4. pkgdepends::install_package_plan(plan, lib = private$library, num_workers = nw, …
5. base::withCallingHandlers({ …
6. pkgdepends:::handle_events(state, events)
7. pkgdepends:::handle_event(state, i)
8. pkgdepends:::stop_task(state, worker)
9. pkgdepends:::stop_task_build(state, worker)
10. base::throw(pkg_error("Failed to build source package {.pkg {pkg}}.", …
11. | base::signalCondition(cond)
12. global (function (e) …
#### Versions
<details>
[Paste the output of `sessionInfo()` leaving a blank line after the details tag]
</details>
Remove every usage of counts() or other related assay selection functions. Use assay() instead that the assay can be selected with a parameter
When installing with pak::pkg_install("omnideconv/spacedeconv", dependencies = T) the wrong DWLS version is installed
Introduce check to prevent SpaceDeconv from failing if rownames come in the wrong format.
(For Example: Inputting ENSEMBL IDs but running immunedeconv functions, it will start but fail directly)
Hello,
I was reasoning on the fact that only a few omnideconv-supported methods use somehow the input bulk RNA-seq data in the process of signature building (@LorenzoMerotto do you remember which ones?). All the others only use single-cell data.
In SpaceDeconv, wherever possible, it would be make sure we decouple the steps of signature building (run only once using the single-cell data) from actual deconvolution (run for all spots) to speed up the analysis.
This would be also reasonable for omnideconv, although the samples to be deconvoluted are << the spots in spatial transcritomics.
Are we already analyzing the data in this way with all methods, or do we build N times the signature matrix?
Curious to know your thoughts @mlist @LorenzoMerotto @grst @alex-d13 @constantin-zackl @federicomarini
Ciao,
Francesca
This is a collection of SpaceDeconv deconvolution tools. Feel free to edit or comment. @omnideconv/core-team
Implemented (or not yet )
Will not be used:
Our normalization function is called "normalize" which introduces problems because many packages have a function named like this. Any ideas for a new name?
Since deconvolution tools typically crash when spots contain all zero values we remove those before we start the deconvolution. However, it might make sense to parameterize this with true as default, this way the users can still decide...
How should omnideconv and immunedeconv methods be named in SpaceDeconv?
I think it doesn't make much sense to use "omnideconv" as method and introduce a "submethod", so we have basically two options:
As the methods have different scopes (for example first / second generation differences) a prefix could be a useful solution or we just introduce all methods in the spaceDeconv documentation
After the deconvolution, the cell types are set to present or absent based on a threshold value. Density plots for the number of present cells per spot based on a specific threshold would be nice for each cell type.
Furthermore, the representation of the score distributions for all cell types together using violine plots could be implemented as well.
Move as many dependencies as possible to "suggests"
Extraction of cell type name from mcp_counter_celltypes does not work as intendet. I tried to use plot_celltype_presence(spe, cell_type = "mcp_counter_B.cell") but it does not work. The problem should be the extraction of the method from the cell type name.
Example:
unlist(strsplit("mcp_counter_B.cell", "_"))[1]
[1] "mcp"
The function adding deconvolution results to objects seems to be buggy if the dimensions of the data don't match.
The solution to fill the empty slots with NAs is okay but the data is not in the right order after this
The normalization function saves the normalization in a different assay, but SpaceDeconv is currently only loading from counts assay.
Update all functions accordingly, this includes a call of SingleCellExperiment::assays(object, assayname) instead of SingleCellExperiment::counts()
Immunedeconv requires HGNC symbols. The spatial datasets i worked with typically contained ENSEMBL / some form of gene symbol but not all HGNC.
Is this something we should require the user to manage or would it be benefical to implement something to convert the gene names? Often a simpel toupper() is kind of fixing the issue.
Trying to cut down on dependencies here :)
The toupper() solution fixes the HGNCs that are present in lowercase. All other genes are "filtered" by the intersect step between signature and sample as performed in omnideconv. This could remove genes which are otherwise "usable".
We should bring SpaceDeconv to a minimal "package ready" form.
Type checks TODO:
Please add/comment any additional tasks @FFinotello @FranziChiara @mzopog
Additional Features and Methods can still be added but we want to focus on the overall pacakge here
Reimplement cpm normalization to work on sparse matrices
Add a correlation plot to access signature quality
Could also copy from DeconvExplorer and add signature clustering
Add alpha/transparency option to plotting function. Goal: Plot one celltype and instead of black (zero expression/abundance) the plot is transparent.
--> Expression overlaying the tissue.
Maybe also a new plotting function.
Add option for black background
The density distribution of the plot_umi_count function results in just a red line without the density distribution graph in the case of very unequal distributions.
In the vignette show how to add manual annotation/ground truth to a spatial object.
Potentially add a nice utility function for this
There is a notification appearing all the time when loading a spatial dataset:
Found more than one class "SpatialImage" in cache; using the first, from namespace 'SpatialExperiment'
Also defined by ‘SeuratObject’
Probably SpatialExperiment related but kind of annoying, so either suppress the message or fix the namespace loading / manually unload the spatialImage from Seurat.
Create Table with time and Memory / CPU / resource expectations for different methods
In several places we access surrounding spots, usually by measuring the distance between all spots to the center and using a limit / circle radius parameter. This approach comes with several downsides:
We should find a way to compute robust iniches. ideally in a recursive manner, without loosing spots due to parameter settings.
I would like to have a function for plotting the number of detected genes as spatial plot and the density distribution beside.
Update Aggregation function to support a list of multiple cell types to aggregate, not just two
The color-mapped density distribution from SpaceDeconv::plot_celltype()
continues to have some problems so i removed the color mapping. As this was a nice feature i would like to reintroduce this in the future but the whole "aes / variable not found" game should be fixed.
the function call contained a fill = after_stat(x) argument which caused a lot of trouble while rendering markdowns. I also tried wrapping it in aes_ or aes_string but this did not solve the issue.
Subsetting shows an inaccurate cell number as output. The subset is fine, just the printed number is wrong!
For reproducibility
Check for zero variable genes and remove them
Metacell exports three different assays. The first one is named "metacell_counts"
Our RCTD wrapper does check for an assay named "counts" as the software requires unnormalized counts.
Change the implementation to support any assay and perform integer checking in another way.
The localization_heatmap function does not consider iniches for the correlation. The iniches could be computet with the get_inichefunction, then the scores within the iniche might be averaged to enable for cell pair wise correlation analysis.
Concerning the discussion about (pre)processing steps earlier today: i am working with a deconvolution method wich does not produce estimations for all spots, only those who match internal criteria. The returned result table contains information for less spots than originally intended. This is not very beneficial for adding the deconvolution results back to the input object.
Does it make sense to just set all the estimations for missing spots to zero? Na or NULL is quite unhandy when working on the visulization afterwards. The thing is the deconvolution did not estimate zero, there is just no estimation for the spot.
One can bypass this problem by manually resetting and lowering the methods QC parameters but then it is not running as recommended.
To improve the deployment time we should introduce a small test dataset with only a few spots for fast deconvolution
Remove the Density plot for discrete color scales as this does not make any sense there
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.