scanpy
scanpy copied to clipboard
Add "sort_by" in rank_genes_groups
- [x] 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?
Hi,
Thanks for developing scanpy, which is quite handy. I am just wondering would it be possible to add a parameter like sort_by
in tl.rank_genes_groups()
, so sorting by logfoldchanges could be feasible for each group. Or I will appreciate it if you can help me with alternatives.
I understand this might be a minor thing, so please feel free to say no :)
Thanks, Nan
The tl.rank_genes_groups
function already sorts genes by their statistic score from greatest to smallest.
If you want to sort the genes by log fold change from greatest to smallest, you can get the pandas dataframe of genes for each group and sort them using pandas function.
df = sc.get.rank_genes_groups_df(adata, group="1")
df_sorted = df.sort_values('logfoldchanges', ascending=False)