Skip to content

Add twas_weights_conversion for legacy twas weights and fix cTWAS - #1427

Open
jaempawi wants to merge 1 commit into
StatFunGen:mainfrom
jaempawi:twas-weights-conversion
Open

jaempawi wants to merge 1 commit into
StatFunGen:mainfrom
jaempawi:twas-weights-conversion

Conversation

@jaempawi

Copy link
Copy Markdown
Contributor

TWAS weights released on Synapse use the legacy list layout, which pecotmr 0.8.2 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 "" 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.

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant