theislab / graphcompass

GraphCompass: Graph Comparison Tools for Differential Analyses in Spatial Systems
MIT License
32 stars 0 forks source link

missing samples in distance.compare_conditions #46

Closed mihem closed 8 months ago

mihem commented 8 months ago

@merelkuijs Thanks again for this package. I like the cell specific comparisons between conditions. When i ran these with my data on 4 samples this worked fine.

When I then ran the same code on all 8 samples I got the following error:

gc.pl.distance.compare_conditions(
    adata=adata,
    library_key=library_key,
    condition_key=condition_key,
    control_group=control_group,
    add_ncells_and_density_plots=True,
    palette="Reds",
    dpi=300,
    figsize=(5,4),
    save="portrait.pdf"
)
KeyError: "['S04'] not in index"

I could resolve this by removing S04 (and also S01, which were both included in my previous version with the four samles where everything worked).

adata_subset = adata[~adata.obs["sample"].isin(["S04", "S01"])]

However, this is not really what I want. I thought at the beginning the the problem lies in the plotting function, but by inspecting the pairwise similarities in adata.uns i saw that S01 and S04 were indeed missing.

image

Actually, I would like to compare all samples to CTRL samples S22 and S24, so next to S01 and S04 I also miss S22 to S11, S22 to S14; S22 to S29; ;and S24 to S29; or do i misunderstand something here?

I followed the code in the tutorial and

gc.tl.distance.compare_conditions(
    adata=adata,
    library_key=library_key,
    cluster_key=cluster_key,
    method="portrait",
    compute_spatial_graphs=False,
)

ran without problems.

Happy to share data and code if that helps.

Thank you!!

mayarali commented 8 months ago

Hello @mihem,

Thanks for raising this issue! Indeed we found a bug in the code that led to these missing comparisons, it should be fixed now. Can please try it out with the new release 0.1.2 and confirm if it is working properly now?

mihem commented 8 months ago

Hey @mayarali thanks for your fast repsonse! Indeed this fixes this issue thanks!

One small question: My graphs look like this right now

image

Why is the upper part of the color legend white in the pariwise similarities? Also I think there should be a legend for the dotplot size (as you showed in your preprint). Thanks!

mayarali commented 8 months ago

Hi @mihem. You're right the variance legend was not included the release. It should be there now in 0.1.3 as well as fixing the colorbar. Let us know if you have any further questions!

mihem commented 8 months ago

perfect, thanks!