-
Notifications
You must be signed in to change notification settings - Fork 8
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
Refactoring with MuData #26
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
A few general comments:
- You should consider adding all doc related files to the gitignore. They pollute pull requests. A CI job should build the docs and with for example RTD integration you can also preview the docs before merging. This does not matter for our pertpy plans, but wanted to write it nevertheless.
- A couple of tools of pertpy have a "load" function that prepares the input for the subsequent tool. I could see us having a load function that returns a MuData object (by creating or appending) that is ready for all downstream Milopy steps.
->
milopy = pt.tl.Milopy()
mdata = milopy.load(adata) # adds compositional adata object and returns mdata object
# alternative
mdata = milopy.load(mdata_old, rna="rna") # where rna refers to the existing RNA modality in the AnnData object
- I didn't add this comment everywhere, but we should ensure that the naming is consistent with unwritten muon/MuData usage rules -> "rna" and "compositional" ("samples" might be too unspecified). Likely should even name it "milo_compositional", because tascCODA might add its own "compositional"
== 1, "nhood_kth_distance"].values | ||
# adata.uns["sample_adata"] = sample_adata | ||
# Make MuData object | ||
milo_mdata = MuData({"cells": adata, "samples": sample_adata}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what happens if I already use a MuData object as input?
The new sample_adata should in this case be added to the existing MuData object.
Also think that the naming is a bit off. The objects inside the MuData object are usually named according to the modality -> adata should be "rna" and sample_adata should be "compositional" or so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, I would parameterize this a bit more to allow for more flexibility of the inputs (and potentially the naming of the newly added modality)
|
||
import matplotlib.pyplot as plt | ||
import seaborn as sns | ||
|
||
|
||
def plot_nhood_graph( | ||
adata: AnnData, | ||
milo_mdata: MuData, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to ensure here that we're using the RNA + compositional modalities. Need good checks for this and sane defaults.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation only uses milo_mdata["compositional"] for plotting. Do you mean we need to use both RNA + compositional modalities? @Zethson
@xinyuejohn started with the integration of milopy into pertpy here: scverse/pertpy#165 What do you think? |
Hi @Zethson |
As for your comment 2, the current workflow works like this:
Therefore, if I need to add a |
What I had in mind is that the load function only generates the actual object that we will use for downstream tasks and not that it does any computation already. It basically only sets up the MuData object. Does it make sense? |
Makes sense to me and it makes the whole pipeline more clear. |
The original cell-level AnnData object and the sample x nhoods AnnData are stored in a common MuData object with
.mod
cells
andsamples
. Samples are inmdata["samples"].obs
and nhoods are inmdata["samples"].var
.Notes
make_nhoods
function is left as is, the MuData object gets created bycount_nhoods
. The rationale is that here samples are not taken into consideration yet.axis
as defined in MuData documentation, since neither.obs
nor.var
are shared between cells and samplesTo do