QuantNado
quantnado.api.QuantNado
¶
Unified facade for QuantNado genomic analysis.
Wraps a MultiomicsStore (or a bare BamStore) and provides
properties to access each modality plus convenience methods for
coverage-based analysis (reduce, extract, count_features, pca,
metaplot, tornadoplot, heatmap, correlate, normalise).
Construction
qn = QuantNado.open("dataset/") # MultiomicsStore directory qn = QuantNado.open("coverage.zarr") # BamStore only qn = QuantNado.from_bam_files( # BAM-only dataset ... bam_files=["s1.bam", "s2.bam"], ... store_path="coverage.zarr", ... ) qn = QuantNado.create_dataset( # multi-omics dataset ... store_dir="dataset/", ... bam_files=["s1.bam"], ... methylation_files=["s1.bedGraph"], ... )
Modality access
qn.coverage # BamStore | None qn.methylation # MethylStore | None qn.variants # VariantStore | None qn.modalities # ['coverage', 'methylation', ...]
Source code in quantnado/api.py
methylation
property
¶
The methylation sub-store, or None if not present.
metadata
property
¶
Metadata DataFrame. Combined across all modalities if multiomics.
open_dataset
classmethod
¶
Open an existing QuantNado dataset.
Auto-detects whether path is a MultiomicsStore directory or a
single BamStore (.zarr).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Path to the store directory or |
required |
read_only
|
bool
|
If True, disables write operations (BamStore only). |
True
|
Returns:
| Type | Description |
|---|---|
QuantNado
|
|
Source code in quantnado/api.py
from_bam_files
classmethod
¶
from_bam_files(
bam_files: list[str],
store_path: "str | Path",
chromsizes: "str | Path | dict[str, int] | None" = None,
**kwargs,
) -> "QuantNado"
Create a QuantNado dataset from BAM files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bam_files
|
list of str
|
BAM file paths. |
required |
store_path
|
str or Path
|
Output Zarr store path. |
required |
chromsizes
|
str, Path, dict, or None
|
Chromosome sizes. Extracted from first BAM if not provided. |
None
|
**kwargs
|
Passed through to |
{}
|
Returns:
| Type | Description |
|---|---|
QuantNado
|
|
Source code in quantnado/api.py
create_dataset
classmethod
¶
create_dataset(
store_dir: str | Path,
bam_files: list[str | Path] | None = None,
methylation_files: list[str | Path] | None = None,
vcf_files: list[str | Path] | None = None,
chromsizes: str | Path | dict[str, int] | None = None,
metadata: DataFrame | Path | str | None = None,
*,
sample_column: str = "sample_id",
bam_sample_names: list[str] | callable | None = None,
methylation_sample_names: list[str] | None = None,
vcf_sample_names: list[str] | callable | None = None,
filter_chromosomes: bool = True,
stranded: list[str] | dict[str, str] | None = None,
overwrite: bool = True,
resume: bool = False,
max_workers: int = 1,
chunk_len: int = DEFAULT_CHUNK_LEN,
construction_compression: str = "default",
local_staging: bool = False,
staging_dir: str | Path | None = None,
test: bool = False,
log_file: Path | None = None,
) -> "QuantNado"
Create a new QuantNado dataset from genomic files.
At least one of bam_files, methylation_files, or vcf_files
must be provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store_dir
|
str or Path
|
Output directory. Created if it does not exist. |
required |
bam_files
|
list of Path
|
BAM files for per-base coverage storage. |
None
|
methylation_files
|
list of Path
|
Methylation files of any supported type. File type is detected from
the filename: |
None
|
vcf_files
|
list of Path
|
VCF.gz files (one per sample) for variant storage. |
None
|
chromsizes
|
str, Path, or dict
|
Chromosome sizes. Extracted from the first BAM if not provided. |
None
|
metadata
|
DataFrame, Path, or str
|
Sample metadata CSV attached to all sub-stores. |
None
|
sample_column
|
str
|
Column in |
"sample_id"
|
bam_sample_names
|
list of str or callable
|
Override sample names for BAM files. A callable receives each
|
None
|
methylation_sample_names
|
list of str
|
Override sample names for methylation files, in classification order: bedGraph names first, then CXreport, then mC/hmC (one name per sample pair). |
None
|
vcf_sample_names
|
list of str or callable
|
Override sample names for VCF files. A callable receives each
|
None
|
filter_chromosomes
|
bool
|
Keep only canonical chromosomes ( |
True
|
stranded
|
list of str or dict
|
Strand-specific coverage configuration. Two forms accepted:
Example:: |
None
|
overwrite
|
bool
|
Overwrite existing sub-stores. |
True
|
resume
|
bool
|
Resume processing an existing sub-store. |
False
|
max_workers
|
int
|
Parallel threads for processing chromosomes within each sample. Samples are processed sequentially to optimize memory usage. |
1
|
chunk_len
|
int
|
Zarr chunk size for the position dimension (coverage store). |
65536
|
construction_compression
|
('default', 'fast', 'none')
|
Build-time compression profile for the coverage store. |
"default"
|
local_staging
|
bool
|
Build the coverage store under local scratch before publishing. |
False
|
staging_dir
|
str or Path
|
Scratch directory for local staging. |
None
|
test
|
bool
|
Restrict coverage to chr21/chr22/chrY (for testing). |
False
|
log_file
|
Path
|
Path to write BAM processing logs. |
None
|
Returns:
| Type | Description |
|---|---|
QuantNado
|
|
Source code in quantnado/api.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | |
get_metadata
¶
Return metadata as a DataFrame.
If this is a multiomics store, returns combined metadata across all
modalities with a modalities column. Otherwise returns coverage
store metadata.
Source code in quantnado/api.py
to_xarray
¶
to_xarray(
chromosomes: list[str] | None = None,
chunks: str | dict | None = None,
) -> dict[str, xr.DataArray]
Extract the coverage dataset as per-chromosome Xarray DataArrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chromosomes
|
list of str
|
Chromosomes to extract. If None, extracts all. |
None
|
chunks
|
str or dict
|
Dask chunking strategy. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, DataArray]
|
|
Source code in quantnado/api.py
extract_region
¶
extract_region(
region: str | None = None,
chrom: str | None = None,
start: int | None = None,
end: int | None = None,
samples: list[str] | list[int] | None = None,
as_xarray: bool = True,
normalise: str | None = None,
normalize: str | None = None,
library_sizes: Series | dict | None = None,
) -> xr.DataArray | Any
Extract coverage signal for a specific genomic region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
region
|
str
|
Region string e.g. |
None
|
chrom
|
optional
|
Alternative to |
None
|
start
|
optional
|
Alternative to |
None
|
end
|
optional
|
Alternative to |
None
|
samples
|
list of str or int
|
Sample names or indices. If None, uses all completed samples. |
None
|
as_xarray
|
bool
|
Return DataArray; if False return numpy array. |
True
|
normalise
|
('cpm', 'rpkm')
|
Normalise the extracted signal before returning it. If omitted, raw coverage is returned. |
"cpm"
|
normalize
|
('cpm', 'rpkm')
|
American-English alias for |
"cpm"
|
library_sizes
|
Series or dict
|
Total mapped reads per sample, indexed by sample name. Overrides
automatic lookup from the store when |
None
|
Returns:
| Type | Description |
|---|---|
DataArray or ndarray
|
|
Source code in quantnado/api.py
reduce
¶
reduce(
intervals_path: str | Path | None = None,
ranges_df: Any | None = None,
feature_type: FeatureType | str | None = None,
gtf_path: str
| Path
| Iterable[str | Path]
| None = None,
reduction: ReductionMethod | str = ReductionMethod.MEAN,
filter_incomplete: bool = True,
) -> xr.Dataset
Reduce per-sample coverage signal over genomic ranges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intervals_path
|
str or Path
|
Path to BED or GTF file. |
None
|
ranges_df
|
DataFrame or PyRanges
|
Pre-parsed genomic ranges. |
None
|
feature_type
|
FeatureType or str
|
Predefined feature type to extract from GTF. |
None
|
gtf_path
|
str, Path, or Iterable
|
Path(s) to GTF file(s). |
None
|
reduction
|
ReductionMethod or str
|
Aggregation statistic: 'mean', 'sum', 'max', 'min', 'median'. |
"mean"
|
filter_incomplete
|
bool
|
Exclude samples not yet marked complete. |
True
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Dimensions: (ranges, sample). |
Source code in quantnado/api.py
extract
¶
extract(
intervals_path: str | Path | None = None,
ranges_df: Any | None = None,
feature_type: FeatureType | str | None = None,
gtf_path: str
| Path
| Iterable[str | Path]
| None = None,
fixed_width: int | None = None,
upstream: int | None = None,
downstream: int | None = None,
anchor: AnchorPoint | str = AnchorPoint.MIDPOINT,
bin_size: int | None = None,
bin_agg: ReductionMethod | str = ReductionMethod.MEAN,
filter_incomplete: bool = True,
modality: str | None = None,
variable: str | None = None,
samples: list[str] | None = None,
strand_aware: bool = False,
strand: str | None = None,
max_workers: int = 1,
) -> xr.DataArray
Extract signal over genomic ranges.
Routes to the appropriate modality sub-store based on modality.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intervals_path
|
str or Path
|
Path to BED or GTF file. |
None
|
ranges_df
|
DataFrame or PyRanges
|
Pre-parsed genomic ranges. |
None
|
feature_type
|
FeatureType or str
|
Predefined feature type to extract from GTF. |
None
|
gtf_path
|
str, Path, or Iterable
|
Path(s) to GTF file(s). |
None
|
fixed_width
|
int
|
Symmetric window total width centered on anchor. |
None
|
upstream
|
int
|
Bases upstream of anchor (cannot combine with |
None
|
downstream
|
int
|
Bases downstream of anchor (cannot combine with |
None
|
anchor
|
AnchorPoint or str
|
Anchor point: 'midpoint', 'start', or 'end'. |
"midpoint"
|
bin_size
|
int
|
Aggregate positions into bins of this size. |
None
|
bin_agg
|
ReductionMethod or str
|
Aggregation method for binning (coverage only). |
"mean"
|
filter_incomplete
|
bool
|
Exclude samples not yet marked complete (coverage only). |
True
|
modality
|
('coverage', 'methylation')
|
Which sub-store to extract from. Defaults to "coverage". |
"coverage"
|
variable
|
str
|
For methylation: which variable to extract
( |
None
|
samples
|
list of str
|
Subset of sample names. Works for both coverage and methylation. |
None
|
strand_aware
|
bool
|
Per-interval strand routing: |
False
|
strand
|
('+', '-')
|
Force all intervals to use the forward ( |
"+"
|
max_workers
|
int
|
Number of chromosome groups to extract in parallel for coverage data. |
1
|
Returns:
| Type | Description |
|---|---|
DataArray
|
Dimensions: (interval, relative_position|bin, sample). |
Source code in quantnado/api.py
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 | |
count_features
¶
count_features(
gtf_file: str | Path | None = None,
bed_file: str | Path | None = None,
ranges: Any | None = None,
feature_type: FeatureType | str = FeatureType.GENE,
feature_id_col: str | list[str] | None = None,
aggregation: str | None = None,
strand: str | None = None,
assays: list[str] | None = None,
samples: list[str] | None = None,
filter_chromosomes: bool = True,
integerize: bool = False,
fillna_value: float | int | None = 0,
min_count: int = 1,
filter_zero: bool = False,
include_incomplete: bool = False,
) -> tuple[pd.DataFrame, pd.DataFrame]
Generate feature count matrix compatible with DESeq2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gtf_file
|
str or Path
|
Path to GTF file. |
None
|
bed_file
|
str or Path
|
Path to BED file. |
None
|
ranges
|
DataFrame or PyRanges
|
Pre-parsed genomic ranges. |
None
|
feature_type
|
FeatureType or str
|
GTF feature type to extract. |
"gene"
|
feature_id_col
|
str or list of str
|
Column(s) to use as feature identifiers. |
None
|
aggregation
|
str
|
Column to aggregate sub-features by. |
None
|
strand
|
str or int
|
Feature strand filtering or read counting mode:
Int modes require a store built with |
None
|
assays
|
list of str
|
Which assays to include in output. |
None
|
samples
|
list of str
|
Specific sample names to include in counts (e.g., ['RNA-SEM-1', 'RNA-SEM-2']). If provided, only these samples are processed and returned. |
None
|
filter_chromosomes
|
bool
|
Keep only canonical chromosomes ( |
True
|
integerize
|
bool
|
Round counts to nearest integer for DESeq2. |
False
|
fillna_value
|
float or int or None
|
Value to fill NaNs before integerization. |
0
|
min_count
|
int
|
Minimum count threshold for mean masking. |
1
|
filter_zero
|
bool
|
Remove features with zero counts across all samples. |
False
|
include_incomplete
|
bool
|
Include samples not yet marked complete. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
counts |
DataFrame
|
Count matrix (features × samples). |
features |
DataFrame
|
Feature metadata. |
Source code in quantnado/api.py
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 | |
normalise
¶
normalise(
data: "xr.Dataset | xr.DataArray | pd.DataFrame",
*,
method: str = "cpm",
library_sizes: "pd.Series | dict | None" = None,
feature_lengths: "pd.Series | Any | None" = None,
) -> "xr.Dataset | xr.DataArray | pd.DataFrame"
Normalise coverage signal or feature counts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dataset | DataArray | DataFrame
|
Output of :meth: |
required |
method
|
('cpm', 'rpkm', 'tpm')
|
Normalisation method:
|
"cpm"
|
library_sizes
|
Series or dict
|
Total mapped reads per sample, indexed by sample name. Auto-read from the store when omitted (requires store built with current QuantNado version). |
None
|
feature_lengths
|
Series or array - like
|
Feature lengths in base-pairs, aligned to data rows.
Required for |
None
|
Returns:
| Type | Description |
|---|---|
Same type as ``data``, normalised values.
|
|
Examples:
>>> cpm_signal = ds.normalise(ds.reduce(intervals_path="promoters.bed"))
>>> cpm_binned = ds.normalise(binned, method="cpm")
>>> counts, features = ds.count_features(gtf_file="genes.gtf")
>>> tpm = ds.normalise(counts, method="tpm", feature_lengths=features["range_length"])
Source code in quantnado/api.py
pca
¶
pca(
data: DataArray,
n_components: int = 10,
chromosome: str | None = None,
nan_handling_strategy: str = "drop",
standardize: bool = False,
random_state: int | None = None,
subset_size: int | None = None,
subset_strategy: str = "random",
) -> tuple[Any, xr.DataArray]
Run PCA on reduced genomic signal data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Input data with dimensions (feature, sample). Typically output
from |
required |
n_components
|
int
|
Number of principal components. |
10
|
chromosome
|
str
|
If set, restrict to features from this chromosome (requires "chrom" coordinate). |
None
|
nan_handling_strategy
|
str
|
How to handle NaN values: "drop", "set_to_zero", or "mean_value_imputation". |
"drop"
|
standardize
|
bool
|
Whether to standardize features to zero mean and unit variance before PCA. |
False
|
random_state
|
int or None
|
Random state for PCA reproducibility. |
None
|
subset_size
|
int or None
|
If set, randomly subset to this many features before PCA (for speed). |
None
|
subset_strategy
|
str
|
Strategy for subsetting features: "random" or "top_variance". |
"random"
|
Returns:
| Name | Type | Description |
|---|---|---|
pca_obj |
PCA
|
|
transformed |
DataArray
|
Dimensions: (sample, component). |
Source code in quantnado/api.py
metaplot
¶
metaplot(
data: DataArray,
data_rev: DataArray | None = None,
*,
modality: str | None = None,
samples: list[str] | None = None,
groups: dict[str, list[str]] | None = None,
flip_minus_strand: bool = True,
error_stat: str | None = "sem",
palette: str | list | dict | None = None,
reference_point: float | None = 0,
reference_label: str = "TSS",
xlabel: str = "Relative position",
ylabel: str | None = None,
title: str = "Metagene profile",
figsize: tuple[float, float] = (8, 4),
ax: Any = None,
filepath: str | Path | None = None,
) -> Any
Plot a metagene profile from the output of .extract().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Output of |
required |
modality
|
str
|
Sets ylabel and colour defaults: "coverage", "methylation", "variant". |
None
|
samples
|
list of str
|
Subset of samples to plot (ignored when |
None
|
groups
|
dict {label: [samples]}
|
Group samples for averaging with inter-sample error bands. |
None
|
flip_minus_strand
|
bool
|
Reverse minus-strand intervals so all profiles run 5'→3'. |
True
|
error_stat
|
('sem', 'std', None)
|
Shaded confidence band. |
"sem"
|
reference_point
|
float or None
|
X position of the vertical reference line. None omits it. |
0
|
reference_label
|
str
|
Legend label for the reference line. |
"TSS"
|
xlabel
|
str
|
Axis labels and figure title. |
'Relative position'
|
ylabel
|
str
|
Axis labels and figure title. |
'Relative position'
|
title
|
str
|
Axis labels and figure title. |
'Relative position'
|
ax
|
matplotlib Axes
|
Axes to draw on; creates a new figure if None. |
None
|
filepath
|
str or Path
|
Save figure to this path if provided. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
ax |
Axes
|
|
Source code in quantnado/api.py
988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 | |
tornadoplot
¶
tornadoplot(
data: DataArray,
data_rev: DataArray | None = None,
*,
modality: str | None = None,
samples: list[str] | None = None,
sample_names: list[str] | None = None,
groups: dict[str, list[str]] | None = None,
flip_minus_strand: bool = True,
sort_by: str | None = "mean",
vmin: float | None = None,
vmax: float | None = None,
scale_each: bool = False,
cmap: str | None = None,
reference_point: float | None = 0,
reference_label: str = "TSS",
xlabel: str = "Relative position",
ylabel: str | None = None,
title: str = "Signal heatmap",
figsize: tuple[float, float] | None = None,
filepath: str | Path | None = None,
) -> list
Tornado / heatmap plot from the output of .extract().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Output of |
required |
data_rev
|
DataArray
|
Reverse-strand data. When provided each panel shows |
None
|
modality
|
str
|
Sets colour defaults: "coverage", "methylation", "variant". |
None
|
samples
|
list of str
|
Subset of samples (one panel each). Ignored when |
None
|
sample_names
|
list of str
|
Display names for samples. |
None
|
groups
|
dict {label: [samples]}
|
Average samples within each group (one panel per group). |
None
|
flip_minus_strand
|
bool
|
Reverse minus-strand intervals before plotting. |
True
|
sort_by
|
('mean', 'mean_r', 'max', None)
|
Sort intervals by signal. |
"mean"
|
vmin
|
float
|
Colour scale limits. |
None
|
vmax
|
float
|
Colour scale limits. |
None
|
scale_each
|
bool
|
Independent per-panel colour scale with a horizontal colourbar beneath each panel. |
False
|
cmap
|
str
|
Matplotlib colormap. |
None
|
reference_point
|
float or None
|
X position of the vertical reference line. None omits it. |
0
|
reference_label
|
str
|
Label for the reference line. |
"TSS"
|
xlabel
|
str
|
|
"Relative position"
|
ylabel
|
str
|
|
None
|
title
|
str
|
|
"Signal heatmap"
|
figsize
|
tuple
|
|
None
|
filepath
|
str or Path
|
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
axes |
list of matplotlib.axes.Axes
|
|
Source code in quantnado/api.py
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 | |
locus_plot
¶
locus_plot(
locus: str,
*,
sample_names: list[str],
modality: list[str],
allele_depth_ref: DataArray | None = None,
allele_depth_alt: DataArray | None = None,
genotype: DataArray | None = None,
coverage: DataArray | None = None,
coverage_fwd: DataArray | None = None,
coverage_rev: DataArray | None = None,
methylation: DataArray | None = None,
palette: str | list | dict | None = None,
title: str = "Locus plot",
figsize: tuple[float, float] = (12, 6),
filepath: str | Path | None = None,
) -> list
Multi-omics genome-browser-style locus plot.
Draws one horizontal track per entry in sample_names, stacked
vertically on a shared genomic x-axis. Coverage and methylation data
are fetched automatically from the store if not explicitly provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locus
|
str
|
Genomic region, e.g. |
required |
sample_names
|
list of str
|
Sample name for each track (must exist in the relevant sub-store). |
required |
modality
|
list of str
|
Modality per track — |
required |
allele_depth_ref
|
DataArray
|
Pre-computed reference allele depth from
|
None
|
allele_depth_alt
|
DataArray
|
Pre-computed alternate allele depth from
|
None
|
genotype
|
DataArray
|
Pre-computed genotype array from
|
None
|
coverage
|
DataArray
|
Pre-computed coverage region array. If None and coverage tracks are requested, fetched automatically from the coverage store. |
None
|
methylation
|
DataArray
|
Pre-computed methylation region array. If None and methylation tracks are requested, fetched automatically from the methylation store. |
None
|
palette
|
str, list, or dict
|
Colour palette. A dict maps sample names to colours. |
None
|
title
|
str
|
Figure title. |
"Locus plot"
|
figsize
|
tuple
|
Figure size |
(12, 6)
|
filepath
|
str or Path
|
Save figure to this path if provided. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
axes |
list of matplotlib.axes.Axes
|
|
Examples:
>>> adr = ds.variants.extract_region(locus, variable="allele_depth_ref").compute()
>>> ada = ds.variants.extract_region(locus, variable="allele_depth_alt").compute()
>>> ds.locus_plot(
... locus="chr21:5200000-5260000",
... sample_names=["atac", "chip", "meth-rep1", "snp"],
... modality=["coverage", "coverage", "methylation", "variant"],
... allele_depth_ref=adr,
... allele_depth_alt=ada,
... title="Multi-omics locus",
... )
Source code in quantnado/api.py
1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 | |
heatmap
¶
heatmap(
data: "xr.Dataset | xr.DataArray | pd.DataFrame",
*,
variable: str | None = None,
samples: list[str] | None = None,
log_transform: bool = True,
cmap: str = "mako",
figsize: tuple[float, float] = (6, 6),
title: str = "Signal heatmap",
filepath: str | Path | None = None,
) -> Any
Clustered heatmap of genomic signal across samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dataset | DataArray | DataFrame
|
Output of |
required |
variable
|
str
|
Data variable to plot when |
None
|
samples
|
list of str
|
Subset of samples to include. Defaults to all samples. |
None
|
log_transform
|
bool
|
Apply |
True
|
cmap
|
str
|
Colormap name. |
"mako"
|
figsize
|
tuple
|
Figure size in inches. |
(6, 6)
|
title
|
str
|
Figure title. |
'Signal heatmap'
|
filepath
|
str or Path
|
Save figure to this path if provided. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
g |
ClusterGrid
|
|
Examples:
>>> signal = ds.reduce(intervals_path="promoters.bed", reduction="mean")
>>> g = ds.heatmap(signal, title="Promoter signal")
Source code in quantnado/api.py
correlate
¶
correlate(
data: "xr.Dataset | xr.DataArray | pd.DataFrame",
*,
variable: str | None = None,
samples: list[str] | None = None,
method: str = "pearson",
log_transform: bool = True,
annotate: bool = True,
cmap: str = "RdBu_r",
figsize: tuple[float, float] = (6, 6),
title: str = "Sample–sample correlation",
filepath: str | Path | None = None,
) -> "tuple[pd.DataFrame, Any]"
Compute and plot a sample–sample correlation matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dataset | DataArray | DataFrame
|
Output of |
required |
variable
|
str
|
Data variable to use when |
None
|
samples
|
list of str
|
Subset of samples. Defaults to all samples. |
None
|
method
|
('pearson', 'spearman')
|
Correlation method. |
"pearson"
|
log_transform
|
bool
|
Apply |
True
|
annotate
|
bool
|
Annotate cells with the r value. |
True
|
cmap
|
str
|
Colormap for the heatmap cells. |
"RdBu_r"
|
figsize
|
tuple
|
Figure size in inches. |
(6, 6)
|
title
|
str
|
Figure title. |
'Sample–sample correlation'
|
filepath
|
str or Path
|
Save figure to this path if provided. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
corr_df |
DataFrame
|
Correlation matrix (samples × samples). |
g |
ClusterGrid
|
|
Examples:
>>> signal = ds.reduce(intervals_path="promoters.bed", reduction="mean")
>>> corr_df, g = ds.correlate(signal, title="Promoter signal correlation")
Source code in quantnado/api.py
1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 | |
set_metadata
¶
Attach metadata to the coverage store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metadata
|
DataFrame
|
|
required |
sample_column
|
str
|
|
"sample_id"
|
merge
|
bool
|
If True, merge with existing metadata. If False, replace entirely. |
True
|
Source code in quantnado/api.py
update_metadata
¶
Update metadata columns using a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
updates
|
dict
|
Column name → list (aligned with sample order) or dict {sample: value}. |
required |