question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Additional parameters in some functions - new functions

See original GitHub issue

Dear all,

I am writing to ask you some other functionalities. I have just moved from Seurat to Scanpy and I am finding Scanpy a very nice and well done Python package.

  1. I wrote a function to show the 3D plot of the UMAP, tSNE and PCA spaces. In the scanpy.tl.tsne function is not possible to change the number of components, it calculates only the first two components, even if the scanpy.pl.tsne function has a parameter component. May you add a parameter like the n_components of the scanpy.tl.umap function?

  2. In the rank_genes_groups function the log2FC values are provided only for ‘t-test’ based methods. May you return the log2FC values (maybe named log2FC) for all the implemented statistical methods?

  3. I think that two parameters in the rank_genes_groups function should be added.

    • min_pCells to test only the genes that are detected in a minimum fraction of cells of either of the two populations (e.g., cluster 0 vs rest). For instance, min_pCells=0.3 means that at least 30% of the cells must express that gene.
    • positive, if it is True, the function should return only positive marker genes for each population.
  4. A function showing the volcano plots (based on the log2FC) can help (I can write it if the log2FC values are provided).

Thank you in advance. Best, Andrea

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:23 (12 by maintainers)

github_iconTop GitHub Comments

6reactions
ivirshupcommented, Mar 16, 2019

Sorry this is a little off topic, but it’s something I’ve found useful:

@LuckyMD and anyone else looking for an interactive volcano plot, I’ve been using hvplot in my notebooks. A volcano plot can be made from DE data frame with something like:

de_df.hvplot.scatter(
    "logfoldchanges", "pvals_adj", 
    flip_yaxis=True, logy=True, 
    hover_cols=["names"]
)
Complete example using scanpy
import pandas as pd
import numpy as np
import hvplot.pandas
import scanpy as sc

def rank_genes_groups_df(adata, group, pval_cutoff : float =None, logfc_cutoff=None): 
    d = pd.DataFrame() 
    for k in ['scores', 'names', 'logfoldchanges', 'pvals', 'pvals_adj']: 
        d[k] = adata.uns["rank_genes_groups"][k][group] 
    if pval_cutoff is not None: 
        d = d[d["pvals_adj"] < pval_cutoff] 
    if logfc_cutoff is not None: 
        d = d[d["logfoldchanges"].abs() > logfc_cutoff] 
    return d

pbmcs = sc.datasets.pbmc68k_reduced()
sc.tl.rank_genes_groups(pbmcs, "bulk_labels", n_genes=pbmcs.var_names.size)
de_df = rank_genes_groups_df(pbmcs, "CD34+")

de_df.hvplot.scatter(
    "logfoldchanges", "pvals_adj", 
    flip_yaxis=True, logy=True, 
    hover_cols=["names"]
)
1reaction
andrea-tangocommented, Mar 12, 2019

@LuckyMD your tutorial is very interesting! I agree with you regarding the min_pCells parameter, it should be used as a filtering step before calculating the marker genes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Write Functions with Multiple Parameters in Python
Luckily, you can write functions that take in more than one parameter by defining as many parameters as needed, for example: def function_name( ......
Read more >
How to pass multiple arguments to function ? - GeeksforGeeks
In the above program, multiple arguments are passed to the displayMessage() function in which the number of arguments to be passed was fixed....
Read more >
Passing Extra Parameters - MATLAB & Simulink - MathWorks
The extra parameters can be data, or can represent variables that do not change during the optimization. There are three methods of passing...
Read more >
The "new Function" syntax - The Modern JavaScript Tutorial
To pass something to a function, created as new Function , we should use its arguments. Summary. The syntax: let func = new...
Read more >
new Function() with variable parameters - javascript
I need to substitute =a with 4 . And yes, I'm well aware than Function is similar to eval() and runs very slow...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found