Skip to content

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

 

History

37 Commits

Folders and files

Repository files navigation

RareCollab

Introduction

RareCollab is a Python package for rare diseases powered by Ollama. It integrates multimodal patient data, including DNA, RNA, and phenotype information, to support candidate variant prioritization and diagnostic interpretation.

Our paper is available on arXiv: https://arxiv.org/abs/2602.04058

Before Running RareCollab

Before running RareCollab, please prepare the following files and directories:

  1. Download the RareCollab data dependencies. No AWS account is needed — --no-sign-request makes the request anonymous. Install the AWS CLI first if you do not have it, then:

    # Change to the directory where you want the data
    cd <desired/folder/path>
    
    # Download
    aws s3 sync s3://rarecollab-data-dependencies-1.0-public/ . --no-sign-request

    The directory you download into is the ref_dir passed to RareCollab.Setup.ResolveReferenceInputs in Step 1.

  2. Create an NCBI API key using your email address from NCBI API Keys. This step is optional, but it can speed up searches using the NCBI and Entrez APIs.

Usage

Installation

Run the code below to install RareCollab:

%pip install git+https://github.com/LiuzLab/RareCollab.git

Step 1. Setup

1.1 Check required command-line tools

import RareCollab

RareCollab.Setup.CheckRequiredTools()

Follow the on-screen instructions to install any missing tools into your target environment.

Tip

When you see the message All required command-line tools are available., all external dependencies have been correctly installed and you can proceed to the next step.

1.2 Configure the paths

# Path to the reference data dependencies you downloaded
ref_dir = '/path/RareCollab-data-dependencies-1.0'

# Path to your working folder (will be created if it does not exist)
work_dir = '/path/work'

#Path to save the final results (will be created if it does not exist)
output_path = '/path/output'

# Reference genome build: 'hg38' or 'hg19'
ref_ver = 'hg38'

1.3 Prepare the references and container images

This step locates the reference files, builds the required indexes, and sets up the Singularity images that the pipeline will use:

# Locate and validate the reference input files for the chosen genome build
references = RareCollab.Setup.ResolveReferenceInputs(ref_dir=ref_dir, ref_ver=ref_ver)

# Build the FASTA index files required for downstream analysis
fasta_references = RareCollab.Setup.BuildReferenceIndex(ref_dir=ref_dir, ref_ver=ref_ver)

# Pull and prepare the Singularity images for the required tools
singularity_images = RareCollab.Setup.PrepareSingularityImages(ref_dir=ref_dir)

# Skip the Ollama image if you will point the agents at an LLM server
# someone else is hosting:
# singularity_images = RareCollab.Setup.PrepareSingularityImages(
#     ref_dir=ref_dir, include_ollama=False)

Each call returns a handle (references, fasta_references, singularity_images) that later steps will use, so run all three before continuing.

PrepareSingularityImages pulls two images into <ref_dir>/singularity_cache: VEP, and Ollama for the LLM server. The first run downloads several gigabytes and converts them to .sif, which takes a few minutes; later runs reuse the files. Doing it here means a GPU job never has to reach Docker Hub itself — on many clusters the compute nodes cannot.

1.4 Load the samplesheet

# Load the samplesheet and validate its configuration
samplesheet = RareCollab.Setup.LoadSamplesheet(csv_path='/path/samplesheet.csv', fulfill_empty_hpo=False)

The samplesheet is a CSV with three required columns: sampleID, vcf_path, hpo_path.

Column requirements
Column Description
sampleID A unique identifier for each sample. Must not be duplicated. Letters, digits, hyphens (-), and underscores (_) are safe to use. To avoid potential parsing issues, it is best to avoid other special characters (such as spaces, /, \, *, or #).
vcf_path The absolute path to the sample's VCF file.
hpo_path The absolute path to the sample's HPO file.

Example: demo/demo_samplesheet.csv.

HPO file format and fulfill_empty_hpo

Each HPO file is a plain-text (.txt) file containing a list of HPO terms, one per line, in the form HP:XXXXXXX.

Example: demo/demo_sample.hpo.txt.

When fulfill_empty_hpo=True, if no HPO file exists at the specified hpo_path, a default HPO file will be created automatically at that location.

Optional sex column

Add a sex column with male, female or unknown per sample. It is carried through to the final report and shown on each patient's HTML page, and it is what lets Step 5 read X- and Y-chromosome variants.

The column is optional: when it is absent the pipeline adds it and fills every row with unknown, so an existing samplesheet keeps working unchanged. A value that is not one of the three is reported and replaced with unknown rather than raising.

Optional RNA columns

RNA analysis is entirely optional — DNA-only analysis is fully supported. To include RNA evidence, add rna_path, strand and pairedEnd to the samplesheet.

Column Description
rna_path The absolute path to the sample's RNA-seq BAM file. Leave the cell empty for samples without RNA; the column may also be omitted entirely to run DNA only.
strand The library's strandedness. One of unstranded (not strand-specific), forward (read 1 in the same orientation as the transcript, fr-secondstrand), reverse (read 1 opposite to the transcript, fr-firststrand/dUTP — the most common protocol for human RNA-seq, including TruSeq Stranded mRNA), or auto (determine it from the BAM).
pairedEnd Whether the library is paired-end. One of yes, no, or auto (determine it from the BAM).

Both strand and pairedEnd are case-insensitive. An empty cell is treated as auto, and so is an absent column — the pipeline adds it for you. A value that is not recognised is replaced with auto and reported as a warning rather than raising, so a typo in an optional column does not stop a run partway through.

Example: demo/demo_samplesheet_withRNABAM.csv.

The two columns are resolved differently when your entry and the file disagree. pairedEnd is measured from the BAM regardless of what you enter, because it is read directly from the alignment flags and takes no extra work — if your entry disagrees with the file, the BAM wins and the difference is reported. strand behaves the other way round: an explicit value is always respected, and detection is only used to flag a possible discrepancy.

Demo files in demo/

The repository ships five examples you can use as a reference for the expected format:


1.5 Configure the worker settings

# Automatically recommend parallelization settings based on the samplesheet
config = RareCollab.Setup.RecommendWorkerConfig(samplesheet)
Adjusting config

At your own risk. You can adjust the parallelization settings in config if needed, but overriding the recommended values may lead to excessive resource usage or unstable runs.


Step 2. Generate Features

Step 2.1. DNA Features from VCF Files

This step turns each sample's VCF into the features used by the downstream analysis. It runs in two stages — first processing the VCFs, then generating the features — and each stage updates samplesheet with the results:

# Stage 1: Process the VCF files (split, normalize, etc.)
samplesheet = RareCollab.Features.ProcessVCF(
    samplesheet,
    config=config,
    work_dir=work_dir,
    references=references,
    fasta_references=fasta_references,
    overwrite=False,
)

# Stage 2: Generate features from the processed VCFs
samplesheet = RareCollab.Features.GenerateFeatures(
    samplesheet,
    work_dir=work_dir,
    references=references,
    fasta_references=fasta_references,
    singularity_images=singularity_images,
    ref_ver=ref_ver,
    config=config,
    overwrite=False,
)

Run both calls in order, since GenerateFeatures depends on the output of ProcessVCF.

Resuming an interrupted run

With overwrite=False, samples whose results already exist in work_dir are skipped, so you can safely re-run this step to resume an interrupted run. Set overwrite=True to force every sample to be reprocessed from scratch.

Step 2.2. RNA Features from BAM Files (Optional)

If RNA-seq data is available, RareCollab can add splicing, expression and allele-specific expression evidence to the diagnosis. This whole step is optional: skip it and the pipeline runs on DNA alone.

2.2.1 Background RNA samples

FRASER and OUTRIDER fit a single model across the entire cohort — they detect how one sample deviates from the others, so a sample has nothing to be an outlier against on its own. DROP recommends at least 50 samples of the same tissue and library protocol. Rare-disease batches are usually far smaller, so additional RNA samples can be supplied purely as background to make the models fittable.

rna_background = RareCollab.Setup.LoadRNABackground(
    csv_path='/path/.../BackgroundRNA.csv',
    existing_sample_ids=samplesheet['sampleID'],
)

If your own cohort is already large enough, skip this and pass None:

rna_background = None
Background samplesheet format

The background samplesheet requires sampleID and rna_path; strand and pairedEnd are optional and follow the same rules as in the main samplesheet. Rows whose BAM does not exist are dropped with a note rather than raising, and background sample IDs must not collide with those in the main samplesheet.

Example: demo/demo_backgroundRNASamples.csv.

The returned table is an ordinary DataFrame, so a background sample that turns out to be unusable can be removed before it reaches the models:

rna_background = rna_background[
    rna_background["sampleID"] != "<sample to drop>"
].reset_index(drop=True)

Tip

Background samples should match the cases in tissue and library protocol; otherwise the outliers detected mostly reflect those differences.

2.2.2 Characterise the BAM files

rna_cohort = RareCollab.Features.ProcessBAM(
    samplesheet=samplesheet,
    rna_background=rna_background,
    work_path=work_dir,
    fasta_references=fasta_references,
    overwrite=False,
)

This builds a .bai index where one is missing, determines each library's strandedness and paired-end status, notes whether the BAM uses chr1- or 1-style contig names, and combines cases and background into a single cohort table. Results are cached per sample, so later runs reuse them unless the BAM itself has changed.

The returned rna_cohort is the table every analysis below consumes.

Why fasta_references matters here

Passing fasta_references turns on a normalisation pass over the case BAMs. GATK sorts intervals into the reference's contig order and then walks the BAM forward only, so a BAM ordered differently loses every contig that sits earlier in its own ordering than the one before it — a lexicographically ordered BAM drops chr10 through chr22, exits cleanly, and says nothing. Contigs the reference lacks are a second problem, aborting the run hours in.

Any case BAM whose contigs disagree with the reference is rewritten with gatk ReorderSam into BAMInfo/<sampleID>/<sampleID>.normalised.bam, and rna_path is repointed at the copy. A BAM that already matches is left alone. Background samples are not normalised: FRASER and OUTRIDER do not care about contig order.

Omit fasta_references to skip the pass entirely.

2.2.3 Run the analyses

Run ASE first. It compares the two alleles within one patient at that patient's own heterozygous sites, so it needs no background, does not depend on which samples it is analysed alongside, and is computed once per patient whatever else happens afterwards.

# Allele-specific expression
rna_cohort = RareCollab.Features.RunASE(
    rna_samples=rna_cohort,
    work_path=work_dir,
    fasta_references=fasta_references,
    overwrite=False,
)

FRASER and OUTRIDER are cohort methods, and measure each case against the background:

# Aberrant splicing
rna_cohort = RareCollab.Features.RunFRASER(
    rna_cohort=rna_cohort,
    work_path=work_dir,
    references=references,
    overwrite=False,
)

# Expression outliers
rna_cohort = RareCollab.Features.RunOutrider(
    rna_cohort=rna_cohort,
    work_path=work_dir,
    references=references,
    overwrite=False,
)

Each call returns rna_cohort with one result-path column appended, so a single variable carries through the whole step. No sample is ever dropped from the table, so a failure in one analysis does not remove that patient from the next. Run only the analyses you want — each is independent of the others.

Controlling parallelism

RunFRASER counts reads per sample and then fits a model across the cohort, and the two stages scale differently:

Argument Stage
count_workers Samples counted at once. Bound by memory — each worker holds one BAM's worth.
fit_threads Threads for the cohort fit. Bound by cores.
n_threads Sets both at once, when you do not want to separate them.

RunOutrider takes n_threads alone. Leave all of them unset to let RareCollab derive values from the machine; the defaults are deliberately conservative, so a large machine is usually worth a explicit value.

Read counting is cached per sample and shared across analyses, so a sample already counted is never counted again — including by a later cohort that reuses the same background.

2.2.4 Attach the RNA evidence to the samplesheet

rna_evidence = RareCollab.Features.PrepareRNAEvidence(
    rna_cohort=rna_cohort,
    samplesheet=samplesheet,
    work_path=work_dir,
)

samplesheet = RareCollab.Features.MergeRNAEvidence(
    samplesheet, rna_evidence, work_path=work_dir,
)

PrepareRNAEvidence reshapes each analysis output into the form the diagnostic engine reads and records the paths; MergeRNAEvidence puts those rows back into the full samplesheet and writes samplesheet_with_paths.csv. Whatever exists is used: if only one or two of the three analyses were run, or one failed for a single patient, the remaining evidence still comes through and the missing columns are simply left empty. Patients with no RNA at all pass through untouched.

Running several case/background combinations

A patient measured against two different background cohorts gets two different FRASER and OUTRIDER answers, and both are worth keeping — so each combination is run under its own analysis_name, and the results are merged at the end.

ASE is unaffected: it is per-patient, so it is still run once, before any splitting, exactly as above.

Split the cohort table into one case plus the shared background per analysis:

import pandas as pd

controls = rna_cohort[rna_cohort["sample_type"] == "control"]

cohort_a = pd.concat(
    [rna_cohort[rna_cohort["sampleID"] == "<case A>"], controls],
    ignore_index=True)
cohort_b = pd.concat(
    [rna_cohort[rna_cohort["sampleID"] == "<case B>"], controls],
    ignore_index=True)

Run the cohort methods on each, naming the analysis:

for cohort, name in ((cohort_a, "case_a"), (cohort_b, "case_b")):
    cohort = RareCollab.Features.RunFRASER(
        rna_cohort=cohort, work_path=work_dir, references=references,
        analysis_name=name, count_workers=12, fit_threads=32)
    cohort = RareCollab.Features.RunOutrider(
        rna_cohort=cohort, work_path=work_dir, references=references,
        analysis_name=name, n_threads=32)

Prepare each separately, then merge them all in one call:

evidence_a = RareCollab.Features.PrepareRNAEvidence(
    rna_cohort=cohort_a, samplesheet=samplesheet,
    work_path=work_dir, analysis_name="case_a")

evidence_b = RareCollab.Features.PrepareRNAEvidence(
    rna_cohort=cohort_b, samplesheet=samplesheet,
    work_path=work_dir, analysis_name="case_b")

samplesheet = RareCollab.Features.MergeRNAEvidence(
    samplesheet, evidence_a, evidence_b, work_path=work_dir)

The merged samplesheet holds one row per (patient, analysis). A patient who appears in two analyses occupies two rows carrying two sets of RNA paths; patients with no RNA keep their single row. Everything downstream reads analysis_name off the row, so the whole samplesheet goes through the rest of the pipeline in one pass rather than once per analysis.

analysis_name defaults to my_work, which writes into the same directories earlier versions used — a cohort that is never split never has to know the concept exists.


Step 3. Score variants and select candidates

With DNA features generated — and RNA evidence attached, if any — the diagnostic engine scores every variant and narrows the list down to the candidates worth an expert opinion.

# Run the Mixture-of-Experts (MoE) diagnostic engine
samplesheet = RareCollab.DiagnosticEngine.MoE(
    samplesheet=samplesheet,
    work_dir=work_dir,
    references=references,
)

# Generate the candidate gene/variant list
samplesheet = RareCollab.DiagnosticEngine.Candidates(
    samplesheet=samplesheet,
    work_dir=work_dir,
    config=config,
    overwrite=False,
)

Step 4. Run RareCollab Agents

4.1 Launch the LLM Server

The agents talk to an Ollama server over HTTP. Start one by whichever route fits your machine, then capture its connection details into llm_config — the rest of the pipeline only ever sees llm_config.

Both launchers find their own dependencies. A notebook kernel inherits the environment that started it, which on a cluster is routinely shorter than what a terminal shows: sbatch, SLURM_CONF and singularity normally arrive through /etc/profile.d or a module, and neither runs for a non-login shell. RareCollab asks a login shell for them rather than asking you to export anything, and when it still cannot find one it says which launch route is available on that machine instead.

Option A — on a SLURM cluster
server = RareCollab.Setup.LaunchLLMServer(
    partition="partition",
    nodelist="node",
    mem="64G",
    port=12321,
    num_parallel=2,
    model_name="gpt-oss:20b",
    job_name="ollama_server",
    log_dir=work_dir,
    cpus_per_task=1,
    gpus=1,
    timeout_seconds=300,
)
Parameters
Parameter Type Description
partition str The SLURM partition to launch the server on.
nodelist str A specific node to run on. Leave it unset to let SLURM pick any node in the partition — pinning to one node means queueing behind whoever is already using it.
port int The port the server listens on. Change it if the default is already taken on that node.
num_parallel int How many requests the model serves concurrently. This is the throughput dial: it sets OLLAMA_NUM_PARALLEL on the server and is also returned in llm_config, where the agents use it as their worker count. Each extra slot costs a little GPU memory for its KV cache, so on a 40–80 GB card a 20B model comfortably supports 8 or more.
model_name str The model to serve (e.g. gpt-oss:20b). Pulled on first launch, which for a 20B model takes several minutes.
job_name str SLURM job name, also used for the log filename.
log_dir str Where to write <job_name>.log. The server's own output goes here, and it is the first place to look if startup fails.
timeout_seconds int How long to wait for the job to start and for the model to become ready. Raise it on a busy queue, or when the model has not been pulled on that node before.
mem str SLURM system-memory request, for example "64G". This is CPU RAM, not GPU VRAM — model weights live in GPU memory, which is fixed by the card.
cpus_per_task int CPU cores allocated to the server process.
gpus int GPUs requested via --gres=gpu:N. One is enough for a 20B model at 4-bit (~13 GB); more only helps when the weights do not fit on a single card, and does nothing for throughput.

LaunchLLMServer prints its SLURM job ID at startup, for example Submitted SLURM job id: xxxxxxxx. Keep it — you need it to reconnect to the server later, and to stop it.

Option B — on a machine with its own GPU

No SLURM needed. This starts Ollama on the machine running the notebook, pulls the model if it is missing, and waits until it answers:

server = RareCollab.Setup.LaunchLocalLLMServer(
    model_name="gpt-oss:20b",
    num_parallel=2,
    log_dir=work_dir,
)

That form needs an ollama binary on the machine. On a cluster node you usually cannot install one, but you can run the same image SLURM would:

server = RareCollab.Setup.LaunchLocalLLMServer(
    model_name="gpt-oss:20b",
    port=12321,
    num_parallel=2,
    log_dir=work_dir,
    container=singularity_images.ollama,
)

Take this route when you are sitting on a GPU node that has Singularity but no SLURM client and no ollama — the usual shape of an interactive allocation, and the case where neither of the other options works. Passing singularity_images.ollama uses the .sif pulled during setup; passing RareCollab.Setup.OLLAMA_CONTAINER instead fetches the image from Docker Hub on first use, which the node may not be able to reach.

A server already listening on the port is reused rather than replaced. The server is started detached, so it survives a kernel restart.

Parameters
Parameter Type Description
model_name str The model to serve. Pulled if the server does not already hold it.
port int The port to serve on. 11434 is Ollama's own default.
num_parallel int Requests served at once. Match the agents' num_parallel. More than the GPU's memory allows makes Ollama queue rather than fail, which presents as slowness with nothing in the log.
log_dir str Where ollama-server.log goes. The working directory if empty.
timeout_seconds int Covers startup and the model pull together; a first pull of a 20B model is several minutes on a fast link.
host str 127.0.0.1 keeps the server off the network. Use 0.0.0.0 only to reach it from another machine, and only on a trusted one — Ollama has no authentication.
container str or Path Run Ollama from this image rather than from a binary on PATH: singularity_images.ollama, or Setup.OLLAMA_CONTAINER for the docker:// URI. None uses the host's own ollama.
container_exec str Path to singularity or apptainer. Found automatically; pass it only when it sits somewhere a login shell does not reveal.
Option C — a server that is already running

If someone else maintains the server, or you started one by hand, point at it directly. CheckLLMServer confirms it answers and holds the model, which is worth doing before a run rather than discovering it one failed request at a time, hours in:

RareCollab.Setup.CheckLLMServer("http://<host>:<port>", "gpt-oss:20b")

server = {
    "model_name": "gpt-oss:20b",
    "ollama_url": "http://<host>:<port>",
    "num_parallel": 2,
}
Reconnecting after a kernel restart

Restarting the notebook loses the server variable while the job itself keeps serving. Rebuild the handle by hand rather than relaunching — the node name is in the launch output, and squeue -j <job id> -h -o %N gives it back:

RareCollab.Setup.CheckLLMServer("http://<node>:12321", "gpt-oss:20b")

server = {
    "model_name": "gpt-oss:20b",
    "ollama_url": "http://<node>:12321",
    "num_parallel": 2,
    "job_id": "<SLURM job id>",
}

num_parallel cannot be read back from a running server — use the value it was launched with. A larger number here does not make the server faster; it makes the agents queue, which looks like slowness with a clean log. Keeping job_id means StopLLMServer(server) still works.

Build llm_config

Whichever option you used, server has the same shape:

llm_config = RareCollab.Setup.LLMConfig(
    model_name=server["model_name"],
    ollama_url=server["ollama_url"],
    num_parallel=server["num_parallel"],
    temperature=0.7,
)
Parameters — LLMConfig
Parameter Type Description
model_name str The served model name. Pass through from server["model_name"].
ollama_url str The server's URL. Pass through from server["ollama_url"].
num_parallel int Number of parallel requests. Pass through from server["num_parallel"].
temperature float Sampling temperature. A value of 0.7 is recommended.

The agents call Ollama's native /api/generate endpoint, so the server has to be Ollama. An OpenAI-compatible endpoint — vLLM, a hosted API — will not work without changes to the agent code.

Shut the server down

RareCollab.Setup.StopLLMServer(server)

Pass the server dict from any of the options above. A server that was already running when RareCollab found it is left alone — adopting one does not make it RareCollab's to kill.

4.2 Run the Diagnostic Agents (Serial)

If you have only a single LLM available, run the diagnostic agents serially as shown below. Each agent updates samplesheet and passes it to the next one, so they must be run in order.

We recommend providing an NCBI email and API key — they're used by the database and literature agents. If you don't have them, set both to None.

# NCBI credentials — used by the database and literature agents.
# If you don't have them, set both to None (queries may then be rate-limited).
NCBI_EMAIL = "your_ncbi@email.com"   # or None
NCBI_KEY   = "your-api-key"          # or None

# Database agent: query external databases for each candidate (uses NCBI)
samplesheet = RareCollab.DatabaseAgent.RunAgent(
    samplesheet=samplesheet,
    work_dir=work_dir,
    references=references,
    llm_config=llm_config,
    ncbi_email=NCBI_EMAIL,
    ncbi_api_key=NCBI_KEY,
    config=config,
    overwrite=False,
)

# In-silico agent: run in-silico prediction/analysis on the candidates
samplesheet = RareCollab.InSilicoAgent.RunAgent(
    samplesheet=samplesheet,
    work_dir=work_dir,
    llm_config=llm_config,
    overwrite=False,
)

# Phenotype agent: preprocess the phenotype (HPO) data
samplesheet = RareCollab.PhenotypeAgent.Preprocessing(
    samplesheet=samplesheet,
    work_dir=work_dir,
    references=references,
    overwrite=False,
)

# Phenotype agent: analysis based on HPO terms
samplesheet = RareCollab.PhenotypeAgent.RunAgent_HPO(
    samplesheet=samplesheet,
    work_dir=work_dir,
    llm_config=llm_config,
    overwrite=False,
)

# Phenotype agent: analysis against OMIM
samplesheet = RareCollab.PhenotypeAgent.RunAgent_OMIM(
    samplesheet=samplesheet,
    work_dir=work_dir,
    llm_config=llm_config,
    overwrite=False,
)

# Phenotype agent: analysis from the literature (uses NCBI)
samplesheet = RareCollab.PhenotypeAgent.RunAgent_Literature(
    samplesheet=samplesheet,
    work_dir=work_dir,
    llm_config=llm_config,
    ncbi_email=NCBI_EMAIL,
    ncbi_api_key=NCBI_KEY,
    overwrite=False,
)

RNA agent

If you ran Step 2.2, add the RNA agent. It reads each patient's splicing, expression and allele-specific expression evidence and gives a gene-level and a variant-level reading of it.

samplesheet = RareCollab.RNAAgent.RunAgent(
    samplesheet=samplesheet,
    work_dir=work_dir,
    llm_config=llm_config,
    references=references,
    ref_ver=ref_ver,
    overwrite=False,
)

Step 5. Annotate Inheritance from Relatives (Optional)

Relatives are optional — a singleton analysis is fully supported, and every step before this one is unchanged by their presence. When you do have them, this step reads each candidate variant out of the relatives' own files and records who carries it, so the final report can say whether a variant is de novo, inherited, or carried by both parents.

Nothing here changes a ranking. The annotation is attached to the variants the pipeline already chose, and no candidate is promoted or filtered because of it: the inheritance model that would justify such a move is a judgement about the gene, not about the genotypes, and is left to you.

5.1 Load the trio sheet

Relatives are supplied in a separate CSV, not in the main samplesheet, so a cohort where only some probands have relatives needs no empty columns and no re-run of anything upstream:

# Load the relatives and check them against the samplesheet
trio_sheet = RareCollab.Setup.LoadTrioSheet(
    csv_path='/path/TrioInfo_samplesheet.csv',
    samplesheet=samplesheet,
)
Column requirements
Column Description
probandID The proband this person is related to. Must match a sampleID in the samplesheet.
relation father, mother, or sibling.
sampleID A unique identifier for the relative.
vcf_path The absolute path to the relative's gVCF, with its .tbi index beside it.
sex male, female, or unknown.
affected unaffected, affected, or unknown.

Example: demo/demo_TrioInfo_samplesheet.csv.

A proband may have any subset of these — one parent, both, parents and siblings, or no entry at all. Probands absent from the sheet are annotated as having no relatives rather than skipped, so every sample still carries the same columns into the report.

Why a gVCF, and why the index matters

A plain VCF only records positions where the caller found a variant. A parent whose file lacks the proband's variant may not carry it — or may simply never have been sequenced deeply enough there to say. Those two readings point in opposite directions, and a plain VCF cannot tell them apart.

A gVCF records the reference blocks as well, so the absence of a variant comes with the depth behind it. RareCollab uses that depth: a position inside a reference block with sufficient coverage is a genuine non-carrier, while a position with no coverage is reported as uncalled and explained, not silently counted as a non-carrier.

The .tbi index is looked for beside the gVCF. With it, each proband's candidates are fetched by position in seconds; without it the file has to be read from the start, which is the difference between a second and an hour on a whole-genome gVCF.

Affected relatives

A parent may be affected, and saying so changes what their genotype means: an affected parent carrying the variant supports a dominant reading rather than weakening it, while an unaffected carrier parent argues against one.

RareCollab records affected alongside each genotype and leaves the inference to you. unknown is a real answer and the safe default — it is better than a guess, because a wrong unaffected on a mildly affected parent is the kind of error that quietly rules out the right gene.

5.2 Annotate the candidates

# Scan the relatives' gVCFs at each candidate position
samplesheet = RareCollab.Trio.AnnotateRelatives(
    samplesheet=samplesheet,
    trio_sheet=trio_sheet,
    work_dir=work_dir,
    ref_ver=ref_ver,
    min_dp=10,
    overwrite=False,
)
min_dp

min_dp is the depth at which a reference call is taken as real evidence of non-carriage. Below it, the position is reported as uncalled with the reason attached, rather than being counted as a non-carrier.

What the annotation can and cannot resolve

The guiding rule is that an annotation is either correct or explicitly uncertain — never a confident guess. Where the evidence does not settle the question, the variant is labelled with what is actually known and the reason is recorded in trio_note.

Three cases come up often:

  • One parent only. With just a mother sequenced, a variant she does not carry is de_novo_or_paternal — the father was never looked at. Calling that one de novo would be wrong half the time.
  • Uncovered positions. A reference block can carry MIN_DP=0: the caller emitted a block over a region it never covered. Such a position is reported as uncalled, not as a non-carrier.
  • Repeat tracts. A parent can carry the same insertion or deletion written at a different length — a contraction of the same repeat by a different number of copies. The two alleles are not equal, so a strict comparison calls the variant de novo. RareCollab flags the overlap instead and notes it.

Step 6. Integrate the Results

The final step merges the outputs from all the diagnostic agents into a single integrated result and writes it to output_path:

# Merge all agent outputs into the final integrated result
samplesheet = RareCollab.Integration.Review(
    samplesheet=samplesheet,
    work_dir=work_dir,
    fasta_references=fasta_references,
    output_path=output_path,
    overwrite=False,
)

After this step completes, your final integrated results are available at output_path.

Step 7. Generate HTML Reports (Optional)

The CSVs from the previous step are the complete record, but they are not something to read. This step renders each one as a browsable page and builds an index over the whole cohort:

# One HTML page per report CSV
samplesheet = RareCollab.Integration.GenerateReports(
    samplesheet=samplesheet,
    report_path=report_path,
    work_dir=work_dir,
    overwrite=False,
)

# One index over every report in that folder
RareCollab.Integration.GenerateReportIndex(report_path)

Open <report_path>/index.html to start. Each page carries its own data — the CSV travels inside the HTML as JSON — so the folder can be zipped and sent to a collaborator who opens it offline, with no server and no access to this machine.

Two functions, on purpose

GenerateReportIndex takes nothing but a folder. Every page written by GenerateReports carries a short summary in its own <head>, and the index is built by reading only that — not the CSVs, and not the samplesheet.

This is what makes a split cohort work. If you scatter your samples across instances and run them independently, each instance produces its own pages; copy them all into one folder afterwards and run GenerateReportIndex on it to get a single index over the lot. Pages rendered on different machines, at different times, index exactly like pages rendered in one run. .html files from anywhere else are ignored and reported.

What is on the pages

Each sample's page opens on its candidate list in RareCollab's final order, with every agent's conclusion as a badge. Selecting a row opens that variant in its own tab: the variant and gene details, the family block when relatives were supplied, the RNA evidence, and each agent's full reasoning.

The patient's sex and input HPO terms are shown at the top, and the transmission label appears under the gene in the candidate list and on the Family block's own heading once a variant is open. A patient with no relatives gets the same page with the family block folded away.

The index lists every sample with its sex, HPO count, top candidate and that candidate's conclusions. Searching by gene shows where that gene ranks among each sample's candidates, which is the quickest way to ask "did anyone else in the cohort hit this gene?"

Naming, re-runs, and analysis_name

Reports go in one flat folder, because the index links to them by filename. A patient measured against two RNA background cohorts gets one page per analysis — <sampleID>__<analysis_name>.html — rather than one overwriting the other.

An existing page is left alone unless overwrite=True, so re-running after adding a few samples renders only the new ones. A row whose report CSV is missing is skipped and named, and its report_html_path is left empty rather than pointing at a file that is not there.


Output Format

The integrated results are written as CSV files, one per sample (split by identifier / sampleID). Within each CSV, candidate variants are already ranked

Output column reference

The columns in each output CSV are described below.

Variant & Gene Identity

Column Description
varId Variant ID, formatted as <chrom>_<pos>_<ref>_<alt>. The chr prefix is stripped, and X and Y are written as 23 and 24.
identifier Sample ID.
geneSymbol Gene symbol.
HGVSc Coding-level (cDNA) variant nomenclature in HGVS format.
HGVSc_core Final retained cDNA HGVS string.
HGVSp Protein-level variant nomenclature in HGVS format.
transcript_id Ensembl transcript ID.
geneSymbol_VarId Combined gene-symbol + variant-ID key.
Chromosome Chromosome.
Pos Variant position.

Inheritance & Variant Class

Column Description
dominant 1 = dominant, 0 = not dominant.
recessive 1 = recessive, 0 = not recessive.
zyg Zygosity: 1 = heterozygous, 2 = homozygous, 0 = missing or uncalled. Stored as a float, so it reads as 1.0 / 2.0 / 0.0.
cons_frameshift_variant 1 = frameshift variant, 0 = not.
frame_shift Whether the variant causes a frameshift.
transcript_score Score for the transcript, computed as a weighted sum based on MANE status and the presence of HGVSp/HGVSc.

Gene Constraint Metrics (gnomAD)

Column Description
gnomadGenePLI gnomAD pLI score (probability of loss-of-function intolerance).
gnomadGeneOELof gnomAD observed/expected ratio for loss-of-function variants.
gnomadGeneOELofUpper Upper bound of the gnomAD LOEUF (O/E LoF confidence interval).

Diagnostic Engine (Mixture-of-Experts) Scores

The overall score comes from a Mixture-of-Experts (MoE) model. Each expert module produces a score and a rank.

Column Description
overall_logit Final-layer logit from the MoE model (interconvertible with overall_prob).
overall_prob Overall probability (the sigmoid-transformed overall_logit).
score_Database / rank_Database Score / rank from the Database module.
score_Genetics / rank_Genetics Score / rank from the Genetics module.
score_InSilico / rank_InSilico Score / rank from the InSilico module.
score_Overview / rank_Overview Score / rank from the Overview module.
score_Phenotype / rank_Phenotype Score / rank from the Phenotype module.
Diagnostic_Engine_Rank Final rank from the MoE model.

RNA — OUTRIDER (expression outliers)

All Outrider_* columns require the RNA module; they are empty if RNA was not run.

Column Description
Outrider_pValue OUTRIDER p-value.
Outrider_padjust OUTRIDER adjusted p-value.
Outrider_zScore OUTRIDER z-score (from its fitted distribution).
Outrider_l2f Log2 fold change.
Outrider_rawcounts Raw read counts.
Outrider_RawZscore Z-score computed directly from raw values (differs from Outrider_zScore because OUTRIDER's model z-score is not based on a plain normal distribution).

RNA — FRASER 2.0 (splicing outliers)

All Fraser_* columns come from FRASER 2.0 and require the RNA module; empty if RNA was not run. Names follow FRASER's own terminology.

Column Description
Fraser_GenePvalue Gene-level p-value.
Fraser_pvaluesBetaBinomial_jaccard Beta-binomial p-value for the Jaccard metric.
Fraser_psi5 / Fraser_psi3 PSI values for 5′ / 3′ splice-site usage.
Fraser_rawOtherCounts_psi5 / Fraser_rawOtherCounts_psi3 Raw counts of "other" reads for the psi5 / psi3 metrics.
Fraser_rawCountsJnonsplit Raw non-split read counts at the junction.
Fraser_jaccard Jaccard splicing metric.
Fraser_rawOtherCounts_jaccard Raw "other" counts for the Jaccard metric.
Fraser_delta_jaccard / Fraser_delta_psi5 / Fraser_delta_psi3 Deviation (delta) from expected value for each metric.
Fraser_predictedMeans_jaccard Model-predicted mean for the Jaccard metric.
Fraser_junction_start / Fraser_junction_end Splice junction start / end coordinates. Empty unless the variant physically falls inside an outlier junction, so they are empty for variants selected on expression or ASE evidence alone.

RNA — Allele-Specific Expression (ASE)

ASE_* columns come from the ASE analysis; empty if it was not run.

Column Description
ASE_REF / ASE_ALT Reference / alternate allele.
ASE_REF_COUNT / ASE_ALT_COUNT Read counts supporting the reference / alternate allele.
ASE_ALT_RATIO Fraction of reads supporting the alternate allele.
ASE_PVAL P-value for allelic imbalance.
IS_MAE Whether the variant shows mono-allelic expression.

RNA — Read Support Counts

All ref_* / alt_* columns are RNA-derived; 0 when the RNA module was not run.

Column Description
ref_count_max / ref_count_mean / ref_count_min Max / mean / min reference-allele read counts.
alt_count_max / alt_count_mean / alt_count_min Max / mean / min alternate-allele read counts.

Candidate Selection & Compound Heterozygosity

Column Description
is_compound_het_group Whether the variant belongs to a compound-het group.
evidence_rules Reason(s) the variant was selected as a disease candidate.
find_compound_het Whether the variant is part of a compound het.
partner The paired variant, if this is a compound het.
compound_het_group_id Group ID for the compound-het group, if applicable.

Family / Relatives

Present in every output. When no relatives were supplied for a sample, these columns carry a placeholder saying so rather than being left blank, so the column set does not change between a trio and a singleton.

Column Description
trio_origin Where the allele came from, as far as the relatives supplied can say. Vocabulary below.
mother_state / father_state That parent at this position: het, hom or hemi (carries it), ref (called, does not carry), other (carries a different allele here), nc (not called — no coverage, or below min_dp).
mother_GT / father_GT The parent's genotype, recoded against this variant: 0 = reference, 1 = this allele, x = some other allele.
mother_DP / father_DP Read depth at this position in that parent.
mother_AD / father_AD Reference,alternate read counts in that parent.
mother_affected / father_affected affected, unaffected or unknown, as given in the trio sheet.
sibling_sharing One entry per sibling supplied — the sibling's ID, whether they carry the allele, and their affected status — the three parts separated by vertical bars, the entries by ;.
trio_note Why this reading may be weaker than it looks, joined by ;. Empty when nothing qualifies it.

For example, a variant one sibling shares and the other does not:

sibling_sharing   SIB_A|carries|affected;SIB_B|not_carried|unaffected
trio_note         mother_ref_block;low_complexity_indel
trio_origin

A parent counts as a carrier when their genotype here is het, hom or hemi, and as a cleared non-carrier when it is ref or other — called, with enough depth, and without this allele. A parent who is neither is unknown at this position, and the label says so rather than assuming.

Value Meaning
de_novo Both parents cleared. Neither carries it.
maternal / paternal That parent carries it and the other is cleared.
both_parents_carry Both parents carry the allele.
de_novo_or_maternal / de_novo_or_paternal Neither parent carries it, but only one of them was callable. The named parent is the one still untested, so de novo and inherited from them remain equally open — which is exactly what sequencing that parent would settle.
maternal_father_unknown / paternal_mother_unknown The named parent carries it, but the other was not callable here, so a second carrier parent cannot be ruled out.
hom_one_parent_not_carrier The proband is homozygous but a parent is cleared. A homozygous child needs an allele from each parent, so this is a contradiction rather than a narrowing: uniparental disomy, a deletion opposite the variant, or a miscall. Genotypes alone cannot say which.
unresolved Relatives were supplied, but their genotypes here do not settle the question. trio_note says why.
proband_uncalled The proband has no usable genotype at this position, so there is nothing to trace.
not_applicable A Y-chromosome variant in a female proband.
no_relatives No relatives were supplied for this proband.
not_annotated Step 5 was not run for this sample.

A homozygous proband takes the same vocabulary with a hom_ prefix, so the two readings that survive the check above are hom_maternal_father_unknown and hom_paternal_mother_unknown — the other parent was never callable, which is the only way a homozygous call stays consistent with one known carrier.

Sex chromosomes

Outside the pseudoautosomal regions, a male proband has one copy of X and one of Y, so only one parent can be the source and the other is not consulted:

  • X in a male proband — read from the mother alone. She carries it: maternal. She is cleared: de_novo. Otherwise unresolved.
  • Y in a male proband — read from the father alone, the same way.
  • Y in a female proband — not_applicable.
  • X or Y in a proband whose sex is unknown — unresolved. Which parent to read depends on the proband's sex, so without it there is no reading to give. Supplying sex in the samplesheet is what resolves these.

LLM Agent Judgments

These columns hold the agents' conclusions. Where an agent produced no judgment, the cell names the reason instead, and the matching _Reasoning column spells it out.

Each agent has its own vocabulary:

Agent Conclusion values
Database Against · Neutral · Supporting · Convincing
In-silico Weak · Moderate · Strong
HPO / OMIM / Literature Not Fit · Partial Fit · Good Fit · Stand-Alone Strong Evidence
RNA (gene and variant level) No RNA Evidence · Weak RNA Evidence · Strong RNA Evidence

In place of a judgment, a cell may instead carry one of:

Value Meaning
No ClinVar Record The variant is absent from ClinVar, so there was no submitter evidence to assess. Common for rare variants, and not evidence against pathogenicity.
Not Evaluated The data was there, but below the threshold for asking the model. In-silico reviews the top 100 variants per sample by MoE rank; the RNA agent requires a splicing or expression signal. A coverage limit, not a finding.
Not Searched Outside that agent's remit by design. The Literature agent searches only genes with no HPO phenotype annotation — the candidate novel disease genes — so an annotated gene is never searched.
No Information The source was consulted and held nothing for this gene.
Not Provided The sample supplied no RNA, so no RNA assessment was possible.
No RNA Results RNA was supplied, but this stage produced no results for it — FRASER and OUTRIDER need a background cohort, while ASE does not, so one level can have data when the other does not.
Evaluation Failed The entry should have been evaluated and was not. Worth looking into: the model call failed, or the reference ClinVar table lists a VariationID that ClinVar has since withdrawn. Not a negative finding.
Column Description
Database_Reasoning / Database_Conclusion Reasoning / conclusion from the Database agent.
Database_Zygosity Zygosity call from the Database agent.
HPO_Reasoning / HPO_Conclusion Reasoning / conclusion from the HPO (phenotype) agent.
OMIM_Reasoning / OMIM_Conclusion Reasoning / conclusion from the OMIM agent.
Literature_Reasoning / Literature_Conclusion Reasoning / conclusion from the Literature agent.
Insilico_Reasoning / Insilico_Conclusion Reasoning / conclusion from the in-silico prediction agent.
RNA_GeneLevel_Reasoning / RNA_GeneLevel_Event / RNA_GeneLevel_Conclusion Gene-level reasoning / event / conclusion from the RNA agent.
RNA_VarLevel_Reasoning / RNA_VarLevel_Event / RNA_VarLevel_Conclusion Variant-level reasoning / event / conclusion from the RNA agent.

Flags & Tiering

Column Description
has_repeat_motif Whether the variant sits in a tandem repeat. Computed from the reference genome sequence, so it is populated whether or not RNA was run.
rna_confirms_call_flag An RNA double-check of the DNA call. True by default — including when no RNA was run — so it means the call was not contradicted, rather than confirmed. Set to False only on positive evidence against the call: a mean reference-read count above 20 together with a minimum alternate-read count of 0. Low coverage never demotes.
new_diseasegene_flag Whether this is a novel disease gene.
omim_flag Whether the gene is an OMIM gene.
strong_nom_flag Whether this is a strong candidate.
Tier Grouping by evidence strength: 1 = most relevant, 2 = intermediate, 3 = least relevant / least evidence.
new_rank Updated per-gene rank.

Pairwise Comparison Module

All PairWise* / pairwise_* columns come from the pairwise (head-to-head) comparison module.

Column Description
PairWiseScore Pairwise comparison score.
PairWiseWins / PairWiseLosses / PairWiseTies Number of head-to-head wins / losses / ties.
PairWiseEntityRank Final rank from the pairwise comparison.
PairWiseWithinEntityRank For a compound het, whether this variant is the higher-ranked (1) or lower-ranked (2) member.
pairwise_entity_id Entity ID in the comparison module.
pairwise_entity_type Entity type in the comparison module.

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages