Sample identity API¶
See sample identity checks for selecting inputs, interpreting diagnostics, and using the CLI. These checks compare supplied variant evidence; they do not assign a patient identity from a filename.
Configuration and inputs¶
varcode.SampleCheckConfig(min_depth: int = 10, min_gq: int = 20, require_quality: bool = False, min_shared_snps: int = 100, min_nonreference_snps: int = 20, min_homozygous_snps: int = 20, min_tumor_hom_reference_snps: int = 20, min_genomic_bins: int = 20, genomic_bin_size: int = 100000, max_snps: int = 50000, max_somatic_variants: int = 100000, compatible_concordance: float = 0.98, discordant_concordance: float = 0.9, max_compatible_ibs0: float = 0.01, min_discordant_ibs0: float = 0.05, min_somatic_variants: int = 10, min_shared_somatic: int = 5, min_somatic_overlap: float = 0.2, min_tumor_alt_reads: int = 3, min_tumor_vaf: float = 0.03, max_normal_alt_reads: int = 1, max_normal_vaf: float = 0.02)
dataclass
¶
Configurable, uncalibrated screening thresholds (all reported in output).
Missing DP/GQ are counted but accepted unless require_quality is true.
SNPs use a deterministic, genotype-independent bottom-k locus sketch.
The somatic limit raises an error instead of silently truncating evidence.
varcode.SampleSpec(sample: str, role: Optional[str] = None, label: Optional[str] = None, donor_id: Optional[str] = None, tumor_id: Optional[str] = None, normal_sample: Optional[str] = None)
dataclass
¶
Select a VCF column and optionally declare its role and expected identity.
| PARAMETER | DESCRIPTION |
|---|---|
sample
|
Exact VCF column name. Names are never interpreted as biological roles.
TYPE:
|
role
|
TYPE:
|
label
|
Unique report identifier; defaults to absolute path plus sample name.
TYPE:
|
donor_id
|
Expected identities used to flag contradictions, not scoring inputs.
TYPE:
|
tumor_id
|
Expected identities used to flag contradictions, not scoring inputs.
TYPE:
|
normal_sample
|
Matched normal column in the same VCF (may be unselected for output).
TYPE:
|
varcode.SampleFingerprint(label: str, sample: str, path: str, sha256: str, assembly: str, kind: str, role: str, config: SampleCheckConfig, donor_id: Optional[str] = None, tumor_id: Optional[str] = None, normal_sample: Optional[str] = None, snps: dict = dict(), somatic: dict = dict(), qc: Counter = Counter())
dataclass
¶
Loaded evidence with input provenance and exclusion counts.
Construct with :func:load_vcf_samples. snps maps (chromosome,
position) to (reference base, sorted diploid base genotype), or None for a
conflicting locus. somatic maps normalized allele keys to VAF or None.
Report serialization omits these potentially large, identifying maps.
summary()
¶
Return JSON-compatible metadata and QC, excluding genotypes.
Source code in varcode/sample_identity.py
Loading and comparison¶
varcode.load_vcf_samples(path, *, kind='germline', assembly=None, samples=None, config=None)
¶
Stream a local VCF/VCF.gz into selected sample fingerprints.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Local VCF, optionally gzip compressed. No annotation data is needed.
TYPE:
|
kind
|
TYPE:
|
assembly
|
GRCh37/hg19/b37 or GRCh38/hg38. Required if the header is unrecognized. An explicit value may not contradict a recognized header reference.
TYPE:
|
samples
|
Selection, roles and expectations. Default: all VCF sample columns.
TYPE:
|
config
|
Shared loading and scoring thresholds for the cohort.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list of SampleFingerprint
|
One entry per selected column, including samples with no usable calls. |
Source code in varcode/sample_identity.py
varcode.compare_samples(a, b, *, config=None)
¶
Return pairwise donor/tumor evidence and expectation flags as a dict.
Both fingerprints must have been loaded with the same config. Different
assemblies yield inconclusive results. flags are review prompts;
only expected_donor_mismatch sets identity_conflict to true.
Source code in varcode/sample_identity.py
varcode.check_sample_identity(samples, *, config=None)
¶
Check every unordered pair and return a JSON-compatible cohort report.
At least two uniquely labelled samples are required. No automatic renaming or definitive swap assignment is performed. Config, sample QC, provenance, all pairs and heuristic limitations are included for reproducibility.