Skip to content

Commit

Permalink
update docstr
Browse files Browse the repository at this point in the history
  • Loading branch information
Sichao25 committed Oct 20, 2023
1 parent e570597 commit 4efeff0
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 5 deletions.
8 changes: 5 additions & 3 deletions dynamo/plot/scatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,6 @@ def scatters_interactive(
color: str = "ntr",
layer: str = "X",
plot_method: str = "pv",
highlights: Optional[list] = None,
labels: Optional[list] = None,
values: Optional[list] = None,
cmap: Optional[str] = None,
Expand Down Expand Up @@ -1054,8 +1053,6 @@ def scatters_interactive(
z: the column index of the low dimensional embedding for the z-axis. Defaults to 2.
color: any column names or gene expression, etc. that will be used for coloring cells. Defaults to "ntr".
layer: the layer of data to use for the scatter plot. Defaults to "X".
highlights: the color group that will be highlighted. If highlights is a list of lists, each list is relate to
each color element. Defaults to None.
labels: an array of labels (assumed integer or categorical), one for each data sample. This will be used for
coloring the points in the plot according to their label. Note that this option is mutually exclusive to the
`values` option. Defaults to None.
Expand Down Expand Up @@ -1098,6 +1095,11 @@ def scatters_interactive(
"title": PyVista Export, "raster": True, "painter": True} as its parameters. Otherwise, you can provide a
dictionary that properly modify those keys according to your needs. Defaults to {}.
**kwargs: any other kwargs that would be passed to `Plotter.add_points()`.
Returns:
If `save_show_or_return` is `save`, `show` or `both`, the function will return nothing but show or save the
figure. If `save_show_or_return` is `return`, the function will return the axis object(s) that contains the
figure.
"""

if plot_method == "pv":
Expand Down
2 changes: 1 addition & 1 deletion dynamo/plot/streamtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def plot_3d_streamtube(
save_show_or_return: Literal["save", "show", "return"] = "show",
save_kwargs: Dict[str, Any] = {},
):
"""Plot a interative 3d streamtube plot via plotly.
"""Plot an interative 3d streamtube plot via plotly.
A streamtube is a tubular region surrounded by streamlines that form a closed loop. It's a continuous version of a
streamtube plot (3D quiver plot) and can provide insight into flow data from natural systems. The color of tubes is
Expand Down
83 changes: 82 additions & 1 deletion dynamo/plot/topography.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def plot_fixed_points(
ax: Optional[Axes] = None,
**kwargs,
) -> Optional[Axes]:
"""Plot fixed points stored in the VectorField2D class.
"""Plot fixed points stored in the VectorField class.
Args:
vecfld: an instance of the vector_field class.
Expand Down Expand Up @@ -1509,6 +1509,87 @@ def topography_3D(
s_kwargs_dict: Dict[str, Any] = {},
n: int = 25,
) -> Union[Axes, List[Axes], None]:
"""Plot the topography of the reconstructed vector field in 3D space.
Args:
adata: AnnData object that contains the reconstructed vector field.
basis: The embedding data space that will be used to plot the topography. Defaults to `umap`.
fps_basis: The embedding data space that will be used to plot the fixed points. Defaults to `umap`.
x: The index of the first dimension of the embedding data space that will be used to plot the topography.
Defaults to 0.
y: The index of the second dimension of the embedding data space that will be used to plot the topography.
Defaults to 1.
z: The index of the third dimension of the embedding data space that will be used to plot the topography.
Defaults to 2.
color: The color of the topography. Defaults to `ntr`.
layer: The layer of the data that will be used to plot the topography. Defaults to `X`.
plot_method: The method that will be used to plot the topography. Defaults to `matplotlib`.
highlights: The list of gene names that will be used to highlight the gene expression on the topography.
Defaults to None.
labels: The list of gene names that will be used to label the gene expression on the topography. Defaults to
None.
values: The list of gene names that will be used to color the gene expression on the topography. Defaults to
None.
theme: The color theme that will be used to plot the topography. Defaults to None.
cmap: The name of a matplotlib colormap that will be used to color the topography. Defaults to None.
color_key: The color dictionary that will be used to color the topography. Defaults to None.
color_key_cmap: The name of a matplotlib colormap that will be used to color the color key. Defaults to None.
alpha: The transparency of the topography. Defaults to None.
background: The background color of the topography. Defaults to `white`.
ncols: The number of columns for the figure. Defaults to 4.
pointsize: The scale of the point size. Actual point cell size is calculated as
`500.0 / np.sqrt(adata.shape[0]) * pointsize`. Defaults to None.
figsize: The width and height of a figure. Defaults to (6, 4).
show_legend: Whether to display a legend of the labels. Defaults to `on data`.
use_smoothed: Whether to use smoothed values (i.e. M_s / M_u instead of spliced / unspliced, etc.). Defaults to
True.
xlim: The range of x-coordinate. Defaults to None.
ylim: The range of y-coordinate. Defaults to None.
zlim: The range of z-coordinate. Defaults to None.
t: The length of the time period from which to predict cell state forward or backward over time. This is used
by the odeint function. Defaults to None.
terms: A list of plotting items to include in the final topography figure. ('streamline', 'nullcline',
'fixed_points', 'separatrix', 'trajectory', 'quiver') are all the items that we can support. Defaults to
["streamline", "fixed_points"].
init_cells: cell name or indices of the initial cell states for the historical or future cell state prediction
with numerical integration. If the names in init_cells are not find in the adata.obs_name, it will be
treated as cell indices and must be integers. Defaults to None.
init_states: the initial cell states for the historical or future cell state prediction with numerical
integration. It can be either a one-dimensional array or N x 2 dimension array. The `init_state` will be
replaced to that defined by init_cells if init_cells are not None. Defaults to None.
quiver_source: the data source that will be used to draw the quiver plot. If `init_cells` is provided, this will
set to be the projected RNA velocity before vector field reconstruction automatically. If `init_cells` is
not provided, this will set to be the velocity vectors calculated from the reconstructed vector field
function automatically. If quiver_source is `reconstructed`, the velocity vectors calculated from the
reconstructed vector field function will be used. Defaults to "raw".
approx: whether to use streamplot to draw the integration line from the init_state. Defaults to False.
markersize: the size of the marker. Defaults to 200.
marker_cmap: the name of a matplotlib colormap to use for coloring or shading the confidence of fixed points. If
None, the default color map will set to be viridis (inferno) when the background is white (black). Defaults
to None.
save_show_or_return: Whether to save, show or return the figure. Defaults to `show`.
save_kwargs: A dictionary that will be passed to the save_fig function. By default, it is an empty dictionary
and the save_fig function will use the {"path": None, "prefix": 'topography', "dpi": None, "ext": 'pdf',
"transparent": True, "close": True, "verbose": True} as its parameters. Otherwise, you can provide a
dictionary that properly modify those keys according to your needs. Defaults to {}.
aggregate: The column in adata.obs that will be used to aggregate data points. Defaults to None.
show_arrowed_spines: Whether to show a pair of arrowed spines representing the basis of the scatter is currently
using. Defaults to False.
ax: The axis on which to make the plot. Defaults to None.
sort: The method to reorder data so that high values points will be on top of background points. Can be one of
{'raw', 'abs', 'neg'}, i.e. sorted by raw data, sort by absolute values or sort by negative values. Defaults
to "raw". Defaults to "raw".
frontier: whether to add the frontier. Scatter plots can be enhanced by using transparency (alpha) in order to
show area of high density and multiple scatter plots can be used to delineate a frontier. See matplotlib
tips & tricks cheatsheet (https://github.com/matplotlib/cheatsheets). Originally inspired by figures from
scEU-seq paper: https://science.sciencemag.org/content/367/6482/1151. Defaults to False.
s_kwargs_dict: The dictionary of the scatter arguments. Defaults to {}.
n: Number of samples for calculating the fixed points.
Returns:
None would be returned by default. If `save_show_or_return` is set to be 'return', the Axes of the generated
subplots would be returned.
"""

logger = LoggerManager.gen_logger("dynamo-topography-plot")
logger.log_time()
Expand Down

0 comments on commit 4efeff0

Please sign in to comment.