Skip to content

Simpler gene annotations in plotting functions #646

Open

Description

@gokceneraslan

We typically have some marker information in the form of an Excel sheet, pandas DataFrame, and eventually a Python dictionary. Using these as gene annotations in various plotting functions (not pl.rank_genes_groups_* family but the others) is a very common task and it looks awesome thanks to @fidelram's var_group_* parameters.

It would be even more fantastic to be able to pass simple dict (e.g. the ones we already use in Malte's marker_gene_overlap) to plotting functions where var_group_positions and var_group_labels are populated automatically.

One caveat is that there might be genes covered by multiple keys, but this is similar to supplying overlapping var_group_positions in current api, which can exit with an error.

I already have a function for that but it's absolutely super ugly. I can send a PR after tidying it up, but if anyone else wants to do it, it's perfectly fine.

Activity

  1. LuckyMD commented on May 15, 2019

    @LuckyMD
    Contributor

    I do this all the time as well. Could you enlighten me as to the var_group_* you are talking about? That sounds like it could be very helpful for me.

  2. gokceneraslan commented on May 15, 2019

    @gokceneraslan
    ContributorAuthor
  3. LuckyMD commented on May 15, 2019

    @LuckyMD
    Contributor

    Cool... I haven't used the new plots yet. Looks very handy. Your wrapper is an automated use of var_group_X to label marker genes of particular clusters in these plots?

  4. fidelram commented on May 15, 2019

    @fidelram
    Collaborator
  5. jorvis commented on May 16, 2019

    @jorvis
    Contributor

    I know this is a bit specific, but the current sc.pl.rank_genes_groups() and sc.pl.rank_genes_groups_violin() have a 'gene_symbols' argument to allow display based on other columns in .var. For example, if I have this in Var:

    Var columns:
                       gene_symbol
    index                         
    ENSMUSG00000000001       Gnai3
    ENSMUSG00000000028       Cdc45
    ENSMUSG00000000031         H19
    ENSMUSG00000000037       Scml2
    ENSMUSG00000000049        Apoh
    

    I can just pass 'gene_symbol' as the column I want to be used for any/all displays instead of the ensembl ID all the time. It would be great if something like this were consistently available anywhere gene labels were needed in the plotting functions. Perhaps the common argument would be better called 'display_label' or something like that instead.

  6. LuckyMD commented on May 16, 2019

    @LuckyMD
    Contributor

    I think gene_symbols is pretty widely spread by now, no? It's not everywhere yet, but I've seen it in a bunch of plotting functions recently.

  7. jorvis commented on May 16, 2019

    @jorvis
    Contributor

    Quite possibly, I need to look. Just updated from 1.3.x to 1.4.3 this week.

  8. gokceneraslan commented on May 19, 2019

    @gokceneraslan
    ContributorAuthor

    Cool... I haven't used the new plots yet. Looks very handy. Your wrapper is an automated use of var_group_X to label marker genes of particular clusters in these plots?

    Just to clarify what I meant, current API:

    sc.pl.stacked_violin(pbmc, marker_genes, groupby='bulk_labels', 
        var_group_positions=[(7, 8)], var_group_labels=['NK'])

    My suggestion:

    markers = {'NK': ['GNLY', 'NKG7']}
    sc.pl.stacked_violin(pbmc, marker_genes, groupby='bulk_labels', var_groups=markers)

    It's ok to keep var_group_* parameters I think, for backward compatibility.

  9. added a commit that references this issue on May 27, 2019
  10. added a commit that references this issue on Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions