Skip to content

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
johandahlberg committed Feb 7, 2024
1 parent d8f2060 commit 12ada02
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/pixelator/annotate/aggregates.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""This module contains functions for finding aggregates.
"""Functions for finding aggregates.
Copyright (c) 2022 Pixelgen Technologies AB.
"""
Expand Down Expand Up @@ -46,7 +46,9 @@ def specificity_tau(matrix: np.ndarray) -> np.ndarray:


def call_aggregates(adata: AnnData, inplace: bool = True) -> Optional[AnnData]:
"""We defined aggregates as components where either:
"""Call aggregates on the adata instance.
We defined aggregates as components where either:
- A single or a handful of markers account for almost all of the count data.
These can likely be attributed to single antibodies forming aggregates
- Low tau scores, meaning a an even number of counts for multiple markers.
Expand Down
30 changes: 20 additions & 10 deletions src/pixelator/annotate/cell_calling.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""This module contains functions for doing size-based cell calling.
"""Functions for doing size-based cell calling.
Copyright (c) 2022 Pixelgen Technologies AB.
"""
Expand All @@ -25,7 +25,9 @@ def find_component_size_limits(
component_sizes: np.ndarray,
direction: Literal["lower", "upper"],
) -> Optional[int]:
"""This function will attempt to find a cutoff for a distribution of component sizes.
"""Find component size limits.
This function will attempt to find a cutoff for a distribution of component sizes.
The direction of the cut-off is determined by the `direction` parameter (lower for
min size and upper for max size).
Expand Down Expand Up @@ -64,7 +66,9 @@ def find_component_size_limits(
"""

def log_size_and_rank(df: pd.DataFrame) -> pd.DataFrame:
"""Rank component sizes by size, sort by their rank, and compute the
"""Rank components by size.
Rank component sizes by size, sort by their rank, and compute the
log10 of both the sizes and ranks. The input dataframe must contain
a `size` column with the component sizes. A new dataframe is
returned with two new columns `log10_size` and `log10_rank`.
Expand All @@ -76,7 +80,9 @@ def log_size_and_rank(df: pd.DataFrame) -> pd.DataFrame:
return df

def smooth(df: pd.DataFrame, x_var: str, y_var: str) -> pd.DataFrame:
"""Calculate a smoothing spline of df[x_var] ~ df[y_var]
"""Create a smoothing spline.
Calculate a smoothing spline of df[x_var] ~ df[y_var]
to make it possible to calculate a less unstable derivate.
The input dataframe must contain the `x_var` and `y_var`
columns, a new column `smooth` is added to the returned
Expand All @@ -92,7 +98,9 @@ def smooth(df: pd.DataFrame, x_var: str, y_var: str) -> pd.DataFrame:
return df

def derivatives(df: pd.DataFrame, x_var: str) -> pd.DataFrame:
"""Calculate the first and second derivatives of the smoothed
"""Calculate first and second derivatives.
Calculate the first and second derivatives of the smoothed
`x_var` variable. The input dataframe must contain the
`x_var` and `smooth` columns. The returned dataframe
contains two new columns `der1` and `der2` with the
Expand All @@ -103,7 +111,9 @@ def derivatives(df: pd.DataFrame, x_var: str) -> pd.DataFrame:
return df

def find_der1_vs_der2_outliers(df: pd.DataFrame) -> pd.Series:
"""Find the distance from origo to each component in
"""Find the distance from origo to each component.
Find the distance from origo to each component in
the space df[der1] ~ df[der2], then try to find
outliers in the upper part of component ranks, by
looking at the standard deviation of the distances.
Expand All @@ -122,10 +132,10 @@ def find_der1_vs_der2_outliers(df: pd.DataFrame) -> pd.Series:
return df["rank"] == rank - 1

def minimum_der2(df: pd.DataFrame) -> pd.Series:
"""Find argmin element. The function returns
a boolean Series where the global minimum
of `der2` evaluates to True. The input dataframe
must contain the `der2` column.
"""Find argmin element.
The function returns a boolean Series where the global minimum of `der2` evaluates
to True. The input dataframe must contain the `der2` column.
"""
return df["der2"] == np.nanmin(df["der2"])

Expand Down

0 comments on commit 12ada02

Please sign in to comment.