Skip to content

Commit

Permalink
[FEATURE] Display QC metrics of var #239
Browse files Browse the repository at this point in the history
- display qc metrics of var

- obs might be too big to actually display
  • Loading branch information
Imipenem committed Feb 26, 2022
1 parent fc82473 commit 8a019f1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ehrapy/preprocessing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
norm_scale,
norm_sqrt,
)
from ehrapy.preprocessing._quality_control import calculate_qc_metrics
from ehrapy.preprocessing._quality_control import calculate_qc_metrics, display_qc_metrics
from ehrapy.preprocessing._scanpy_pp_api import * # noqa: E402,F403
from ehrapy.preprocessing.encoding._encode import encode, undo_encoding
23 changes: 23 additions & 0 deletions ehrapy/preprocessing/_quality_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,29 @@ def calculate_qc_metrics(
return obs_metrics, var_metrics


def display_qc_metrics(adata: AnnData) -> None:
"""Displays the calculated quality control metrics for var of adata.
Args:
adata: Annotated data matrix.
"""
from rich.console import Console
from rich.table import Table

table = Table(title="[bold blue]Ehrapy qc metrics of var")
table.add_column("[bold blue]Column name", justify="right", style="bold green")
var_names = list(adata.var_names)

for col in adata.var.columns:
table.add_column(f"[bold blue]{col}", justify="right", style="bold green")

for var in range(len(adata.var)):
table.add_row(var_names[var], *map(str, list(adata.var.iloc[var])))

console = Console()
console.print(table)


def _missing_values(
arr: np.ndarray, shape: tuple[int, int] = None, df_type: Literal["obs", "var"] = "obs"
) -> np.ndarray:
Expand Down

0 comments on commit 8a019f1

Please sign in to comment.