Skip to content

Commit

Permalink
Added working until coredump from robust_se
Browse files Browse the repository at this point in the history
  • Loading branch information
cboix committed Apr 12, 2024
1 parent 4f38c42 commit ed3163a
Show file tree
Hide file tree
Showing 9 changed files with 220 additions and 182 deletions.
46 changes: 24 additions & 22 deletions notebooks/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
suffix=tag,
# imgdir=imgdir, TODO: Set global imgdir?
# Options for graph creation:
estimate_sd=False,
svd_k=max_k, filter_expr=0.05, z=4.5,
# Overall usage/correlation computation options:
calc_raw=False)
svd_k=max_k, filter_expr=0.05)
mod.setup() # Setup the object

# 1. Make a graph using robust_se:
mod.make_graph('rse', method='robust_se')


# Make graph using the selected parameters for basic analysis:
# ------------------------------------------------------------
Expand Down Expand Up @@ -83,25 +83,27 @@
pl.plot_heatmap_avgexpr(mod, graph_id, cvlist=cvlist, attr="leiden")


# Make a graph from multiple resolutions:
# ---------------------------------------
graph_id = 'merge'
mod.make_graph(graph_id, multigraph=True, power=[0,.5,1])
# Make some other graphs based on different methods:
# --------------------------------------------------
# 1. Make a graph using robust_se:
mod.make_graph('rse', method='robust_se')

# Plot these:
pl.plot_genes(mod, graph_id, attr="leiden", show_labels=True, width=16)
pl.plot_heatmap_avgexpr(mod, graph_id, cvlist=['leiden'], attr="leiden")
pl.plot_umap_grid(mod, graph_id)
# 2. Make a graph from multiple resolutions:
mod.make_graph('merge', multigraph=True, power=[0,.5,1])

# 3. Make a graph from the raw correlation:
mod.make_graph('raw', raw=True)

# 4. Remove PCs correlated with the cell clustering (leiden)
mod.make_graph('subset', filter_covariate="leiden")


# Plot these graphs:
# ------------------
graphlist = ['rse', 'merge', 'subset', 'raw']
for graph_id in graphlist:
pl.plot_genes(mod, graph_id, attr="leiden", show_labels=True, width=16)
pl.plot_heatmap_avgexpr(mod, graph_id, cvlist=['leiden'], attr="leiden")
pl.plot_umap_grid(mod, graph_id)

# Make a graph from only specific non-covariate-correlated PCs
# ------------------------------------------------------------
# TODO: cv_cutoff was 2.0
graph_id = 'subset'
# Remove PCs correlated with the cell clustering (leiden)
mod.make_graph(graph_id, filter_covariate="leiden")

# Plot these:
pl.plot_genes(mod, graph_id, attr="leiden", show_labels=True, width=16)
pl.plot_heatmap_avgexpr(mod, graph_id, cvlist=['leiden'], attr="leiden")
pl.plot_umap_grid(mod, graph_id)
3 changes: 3 additions & 0 deletions scdemon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ pl.plot_genes(mo, 'base')

```

### TODO:
- Add pytest tests for basic functionality, with dummy objects or very small dataset


### Old todolist / desirables:
Done
Expand Down
4 changes: 1 addition & 3 deletions scdemon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
)

from .auxiliary import vcorrcoef
from .graph import gene_graph
# from .correlation import correlation
# from .modules import modules # Change
from .graph import gene_graph, adjacency_matrix
from .framework import modules_core # Change

from .plotting import plot_genes, plot_umap_grid, plot_svd_corr
1 change: 0 additions & 1 deletion scdemon/correlation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from .correlation import correlation
from .utils_correlation import (
calculate_correlation,
calculate_correlation_estimate,
Expand Down
Loading

0 comments on commit ed3163a

Please sign in to comment.