scverse / scverse/scanpy

Extend functionality of tl.rank_genes_groups()

Open
#2,317 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.6k
Forks
779
Avg merge
1d 4h
Merged PRs (30d)
27

Description

  • Additional function parameters / changed functionality / changed defaults?
  • New analysis tool: A simple analysis tool you have been using and are missing in sc.tools?
  • New plotting function: A kind of plot you would like to seein sc.pl?
  • External tools: Do you know an existing package that should go into sc.external.*?
  • Other?
  1. I would be great if the reference option in sc.tl.rank_genes_groups() would accept not only 'rest' or a single group identifier, but a list of identifiers (as is possible for the groups option). Currently, lists such as reference=['g1','g2','g3'] are not accepted:

    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    Input In [72], in <cell line: 2>()
          1 # each WT sample individually vs all other WT samples
    ----> 2 sc.tl.rank_genes_groups(remerged_WT, groupby='sample', groups=WT_samples, reference=['g1','g2','g3'], 
    method='wilcoxon')
    
    File D:\Programme\Anaconda\envs\squidpy\lib\site-packages\scanpy\tools\_rank_genes_groups.py:570, in 
    rank_genes_groups(adata, groupby, use_raw, groups, reference, n_genes, rankby_abs, pts, key_added, copy, method, corr_method, 
    tie_correct, layer, **kwds)
    568     if isinstance(groups_order[0], int):
    569         groups_order = [str(n) for n in groups_order]
    --> 570     if reference != 'rest' and reference not in set(groups_order):
    571         groups_order += [reference]
    572 if reference != 'rest' and reference not in adata.obs[groupby].cat.categories:
    
    TypeError: unhashable type: 'list'
    
  2. Also I would appreciate if sc.tl.rank_genes_groups() would allow testing against a reference which is (partly) included in the groups that are being tested. In other words, I would like to test all individual groups ['a','b','c','d'] against a fixed reference ['b','c','d']. Currently, if I test a group which is also set as reference (eg groups=['g1','g2','g3'], reference='g2'), the group (g2) is skipped and not added to adata.uns["rank_genes_groups"]. When using reference='rest', the tested group is excluded from the reference (eg reference is ['b','d'] when ['c'] ist tested).

Much appreciated!
Simon

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with sc.tl.rank_genes_groups() in scanpy/tools/_rank_genes_groups.py and reproduce the reported list-reference TypeError. Trace how groups and reference are validated and how results are stored in adata.uns["rank_genes_groups"]. Done means list-valued references are accepted, overlapping tested groups are handled as requested, and existing behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.