Repository navigation
Conversation
TWAS weights released on Synapse use the legacy list layout, which pecotmr 0.8.x does not read. This adds a protocol-level conversion layer, as agreed, rather than a backwards-compatibility loader in pecotmr. - twas_weights_conversion.R: convert legacy weight RDS (univariate and multicontext) into one pecotmr TwasWeights per gene. Weights and CV metrics are copied unchanged; carries traitPos (gene TSS) for cTWAS block placement; writes the xqtl_meta row and the context -> data type rows. - twas_ctwas.ipynb: new optional twas_weights_conversion workflow (skip it for weights already in TwasWeights format), with Input/Output/MWE docs and the Overview updated; MWE commands now use the converted example tables. - ctwas_1: --gwas_study now selects the GWAS (cTWAS takes one per LD block) and the run fails early if several remain; new --ctwas_method (weights with several methods and no ensemble); pass the chromosome's genotype prefix as --ld-sketch so ctwasPipeline sees a real LD file rather than a "<chrom-meta>" placeholder. - ctwas_assemble.R: drop study elements and LD blocks with no GWAS variants (they carry no genome build and broke combineGwasSumStats). Tested: conversion is exact for eQTL, pQTL and sQTL weights (weights compared element by element); TWAS runs on converted weights for 8 studies in the APOE region; cTWAS assemble passes. cTWAS parameter estimation and fine-mapping are not yet tested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Csueazw8VDi9a3mhLvgjQg
- fine_mapping_conversion.R: convert legacy FunGen-xQTL QTL fine-mapping (*.univariate_bvsr.rds) into pecotmr QtlFineMappingResult, one per study and gene, with the same study/context labels as twas_weights_conversion. - twas_ctwas.ipynb: new optional fine_mapping_conversion step; twas passes --fine-mapping-result when --fine_mapping_dir has a file for the gene, plus --mr_method and --mr_pip_cutoff; Inf is passed to R as Inf; docs note that --rsq_cutoff 0 --rsq_pval_cutoff inf keeps every method. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Csueazw8VDi9a3mhLvgjQg
jaempawi
force-pushed
the
leafcutter2-module
branch
from
October 1, 2026 23:54
15edca7 to
1d55835
Compare
- regtools_junctions.sh: optional --min-mapq (default 0, off). regtools has no mapping-quality filter, so multimapping reads add junction support at every location they map to; --min-mapq 255 keeps STAR's uniquely mapped reads only. - splicing_calling_leafcutter2.ipynb: --min-mapq on the junction step, and a new differential_splicing workflow. It splits the LeafCutter1-format counts by chromosome, runs leafcutter_ds.R on each part as its own job, then joins the parts and recomputes the Benjamini-Hochberg FDR over all clusters, so results match a single unsplit run. - leafcutter_ds_split.py / leafcutter_ds_merge.py: split and join helpers; the split checks the groups file against the count table before any job runs. - leafcutter_ds.R: LeafCutter's script, restricted to samples present in both the counts and the groups file. - Docs: Overview, Input, Output, example, help text and troubleshooting updated; NE and IN label descriptions corrected. - Tests for the split, the FDR recomputation and --min-mapq validation. Checked on a 200-brain cohort: --min-mapq 255 reproduces junctions extracted with samtools view -q 255 exactly, and differential_splicing on chr21/22 gives identical p-values to an unsplit leafcutter_ds.R run.
leafcutter2_2 and leafcutter2_cluster carried the same inline block: the mixed-format and chromosome-naming checks, the leafcutter2 call, and the empty-result check. It now lives once in leafcutter2_cluster.sh, which both steps call, matching the other steps of the module. Outputs on the repository fixtures are byte-identical before and after (junction counts, cluster ratios, LeafCutter1 tables, classifications).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add LeafCutter2 splicing calling module
Adds
splicing_calling_leafcutter2.ipynbalongside the existingsplicing_callingmodule, so LeafCutter1 can eventually be retired. LeafCutter2 adds a functional label to every junction —PR(productive),UP(unproductive / NMD target),NE(ambiguous),IN(intergenic) — appended as a fifth colon field on the intron ID, e.g.chr10:134786:179993:clu_1_+:PR(Dai et al., 2025).The existing module is untouched; this one sits beside it.
Workflows
leafcutter2keeps a default of 1 since its junctions always come from regtools.Guards
Each one tested to fire:
ValueErrorThe
[global]block now derives BAM paths, strandness and sample IDs from one filtered row collection, so a blank orNApath drops that sample without shifting the next one's strand. This bug is inherited verbatim fromsplicing_calling.ipynb, which still has it — worth a follow-up there. It is not silent corruption: SoS fails loudly withLength of provided properties (3) does not match number of groups (2).GTF, FASTA,
.faiand the junction files named in--juncfilesare now declared dependencies.--output-prefixwas added so two workflows can share one--cwd, and so a manifest namedcohort.v1.sample_list.txtdoes not collapse tocohort.Dependency: LeafCutter2 >= 2.0
star2junccallsleafcutter2-star2junc, which exists only in 2.x.The only conda build of leafcutter2 in any of our channels is 0.0.1 (
dnachun/noarch, 2026-01-27) — conda-forge and bioconda have none. It packages the pre-2.0 repository scripts with no__init__.pyand no.dist-info, and its classification step fails with:@dnachun is building 2.0.1 for the channel. Once it lands:
leafcutter2toStatFunGen/pixi-setupenvs/full_packages.txt, besideregtoolsTo reproduce the verified run before then — note LeafCutter2 is not on PyPI, so
pip install leafcutter2fails:Tests
tests/notebooks/molecular_phenotypes/calling/test_splicing_calling_leafcutter2.py, currently2 passed, 1 skipped:test_cluster_requires_explicit_offset— needs no binary and no reference data, so it runs on every CI runner todaytest_star2junc— skips unlessleafcutter2-star2juncis on PATH, which doubles as the >= 2.0 probetest_cluster_and_classify— additionally gated onXQTL_REFERENCE_DATA, since the GTF and FASTA are not in the repository; asserts the five-field ID, thePR/UP/NE/INlabel, thatcluster_ratios.gzcells carry/, and thatjunction_counts.gzdoes notThe guards mean CI is green now and the coverage becomes real the moment the conda package lands, without a red X in the meantime.
Files
code/SoS/molecular_phenotypes/calling/splicing_calling_leafcutter2.ipynbtests/notebooks/molecular_phenotypes/calling/test_splicing_calling_leafcutter2.pytests/fixtures/splicing_calling/leafcutter/protocol_example.sample_list.txttests/fixtures/splicing_calling/leafcutter/protocol_example.bam_list.txttests/fixtures/splicing_calling/leafcutter/protocol_example.junction_files.txttests/fixtures/splicing_calling/leafcutter/SAMPLE_001.SJ.out.tabtests/fixtures/splicing_calling/leafcutter/SAMPLE_002.SJ.out.tabThe two
SJ.out.tabfixtures are new, derived from the shipped.juncfiles, so thestar2juncMWE runs off the repository as written (~1 s). All four MWEs use thetests/fixturesdata withprotocol_example.*naming andSAMPLE_001/SAMPLE_002.