Plotting
scSELpy can be employed to manual select and annotate cells on scanpy generated plots. The following plots are supported: UMAP, TSNE, PCA and scatter plots. All these plots take the normal scanpy parameters, with additonal scSELpy parameters. The scSELpy parameters are the same for all 4, unless specified otherwise.
If none of the above mentioned embeddings work, scSELpy also supports scanpy’s embedding plotting parameter.
UMAP
scselpy.pl.umap(adata,*kwargs)
TSNE
scselpy.pl.tsne(adata,*kwargs)
PCA
scselpy.pl.pca(adata,*kwargs)
Scatter plot
scselpy.pl.scatter(adata,x,y,*kwargs)
For example:
scselpy.pl.scatter(adata,'n_genes','n_counts',color="ATCB")
Embedding
scselpy.pl.embedding(adata,basis=arg,*kwargs)
For example, in order to run umap:
scselpy.pl.embedding(adata,basis="X_umap",color="ATCB")
Parameters
None, list (default: None)None, str, list (default: None)Renaming scSELpy annotations None, str, list (default: '-')-, .,-- and -.. If you want to select 3 polygons, you can pass [".","-","--"] None, str (default: 'upper left')None, tuple (default: (1, 1))None, int, float (default: None)str (default: 'Other')None, str (default: None)Anndata obvservation, on which annotations will be added. For example, load="REMAP_1" (default scSELpy output) or load="leiden_r0.5". For concrete examples please check the toturial. None, str (default: None)Unstructured Anndata annotation stored by an earlier invocation of scSELpy. When this parameter is used, the user can not draw new lines, with the exception for when used together with the load parameter. In the latter case, all previously and newly drawn polygons will be annotated on the loaded Anndata obvservation. bool (default: False)overwrite = False, multiple polygons that overlap the same cell, will have the name annotated to that cell. For example "1,2,3" when Polygon 1, 2 and 3 overlap this cell. In the case that overwrite = True, only the last Polygon will be annotated. Therefore the output will be "3", even when Polygon 1, 2 and 3 overlap it. bool (default: False)mock parameter. bool (default: False)bool (default: False)skip_float_check = True None, dict (default: None)Mock section in the documentation. None, str (default: None)scanpy.set_figure_params should still work. str, None (default: None)float, int (default: 60)bool (default: False)Removed or changed parameters
In general, all scanpy plotting parameters can be passed to the scselpy.pl.* functions, with the exception of:
LayersorLayer
The following parameters have been changed:
componentsin scSELpy, you can only have 2 dimensions. e.g. the 3rd and 4th component.saveAs shown in parameters, scSELpy has its own saving function implemented.
Running other commands (Not supported)
In case the user would like to use scSELpy with other commands, it is technically possible by calling scSELpy’s Remap() function directly and set its internal parameter override to True:
scselpy.pl._scselpy.Remap(adata,override=True,scat_plot=False,basis=<input from obsm>,plotattr=<function>,remove_show_override=True)
scat_plot defines if the entry is a scatter plot. If passing a scatterplot, use the arguments “x_scat” and “y_scat”. Options: “scat”,”embedding” and anything else, e.g. False
plotattr passes the function that we want to run. e.g. sc.pl.umap, sc.pl.draw_graph or maybe even a function that does not stem from scanpy.
remove_show_override disables the scSELpy internal override which always passes show=False to scanpy. The default of remove_show_override=True, this is probabaly the best if not running scanpy directly.
With the following command we run a scatter plot this way:
scselpy.pl._scselpy.Remap(adata,x_scat="n_counts",y_scat="n_genes",override=True,scat_plot="scat",plotattr=sc.pl.scatter,remove_show_override=False)
To run this on e.g. Scanpy’s draw_graph:
scselpy.pl._scselpy.Remap(adata,override=True,scat_plot=False,basis="X_draw_graph_fa",plotattr=sc.pl.draw_graph,remove_show_override=False)
To try this on an external Scanpy-based package, such as Scirpy:
import scirpy as ir
df, dst, lk = ir.tl.repertoire_overlap(adata, "CD4_and_CD8_cells", inplace=False)
dfT = df.T
First = "CD8"
Second = "CD4"
adata.obsm['X_Repertoire'] = np.array([[dfT[First][ID],dfT[Second][ID]] if np.isnan(float(ID)) == False else [0.0,0.0] for ID in list(adata.obs["clone_id"])])
scselpy.pl._scselpy.Remap(adata,override=True,remove_show_override=True,scat_plot=False,basis="X_Repertoire",plotattr=ir.pl.repertoire_overlap,...)
This function only works on scanpy-based packages and if the Anndata object is the only non-keyword argument.