%23%20Copyright%202026%20Riya%20Sinha%0A%22%22%22Tutorial%200%3A%20look%20up%20what%20is%20known%20about%20five%20variants.%22%22%22%0A%0Aimport%20marimo%0A%0A__generated_with%20%3D%20%220.24.2%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22)%0A%0Awith%20app.setup(hide_code%3DTrue)%3A%0A%20%20%20%20import%20json%0A%20%20%20%20from%20pathlib%20import%20Path%0A%0A%20%20%20%20import%20_series%20as%20series%0A%20%20%20%20import%20pandas%20as%20pd%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%0A%20%20%20%20return%20(mo%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%20Tutorial%200%20%C2%B7%20Look%20up%20what%20is%20known%20about%20five%20variants%0A%0A%20%20%20%20This%20tutorial%20looks%20up%20five%20GRCh38%20variants%20in%20three%20public%20datasets%3A%20how%20common%20each%20one%20is%20in%20gnomAD%2C%20how%0A%20%20%20%20ClinVar%20classifies%20it%2C%20and%20how%20conserved%20its%20base%20is%20across%20100%20vertebrates.%20Along%20the%20way%2C%20you%20will%20see%20how%0A%20%20%20%20Altar%20names%20a%20variant%2C%20how%20a%20run%20spec%20describes%20a%20run%2C%20and%20what%20a%20run%20writes.%0A%0A%20%20%20%20By%20the%20end%2C%20you%20will%20be%20able%20to%3A%0A%0A%20%20%20%201.%20load%20a%20cohort%20of%20variants%20and%20read%20their%20variant%20IDs%3B%0A%20%20%20%202.%20write%20a%20run%20spec%20that%20names%20three%20annotation%20sources%3B%0A%20%20%20%203.%20check%20the%20spec%20before%20anything%20is%20read%3B%0A%20%20%20%204.%20run%20it%20and%20read%20the%20export%2C%20column%20by%20column%3B%0A%20%20%20%205.%20explain%20why%20a%20variant%20is%20or%20is%20not%20prioritized%3B%20and%0A%20%20%20%206.%20look%20variants%20up%20from%20Python%20and%20recognize%20a%20variant%20a%20source%20has%20no%20record%20of.%0A%0A%20%20%20%20**Requirements%3A**%20Python%20and%20network%20access.%20The%20run%20reads%20a%20few%20MB%20of%20the%20published%20gnomAD%2C%20ClinVar%20and%0A%20%20%20%20phyloP%20datasets%20from%20a%20public%20Google%20Cloud%20bucket%2C%20with%20no%20credentials.%20It%20needs%20no%20Docker%2C%20GPU%2C%20API%20key%20or%0A%20%20%20%20reference%20genome.%20All%20five%20variants%20are%20single-nucleotide%20variants%20(SNVs)%2C%20so%20they%20need%20no%20reference%20to%20be%0A%20%20%20%20written%20in%20their%20standard%20form.%0A%0A%20%20%20%20This%20is%20the%20first%20notebook%20of%20the%20series.%0A%20%20%20%20%5BTutorial%201%5D(https%3A%2F%2Fkundajelab.github.io%2Faltar%2Fstart%2Fnotebooks%2F01_score_with_cherimoya.html)%0A%20%20%20%20scores%20the%20same%20five%20variants%20with%20a%20model%2C%20and%20Tutorial%203%20puts%20those%20scores%20beside%20the%20evidence%20you%20look%20up%0A%20%20%20%20here.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Series%20settings%0A%0A%20%20%20%20Every%20notebook%20of%20the%20series%20reads%20and%20writes%20one%20work%20directory.%20This%20notebook%20writes%20its%20run%20under%0A%20%20%20%20%60evidence%2F%60%20inside%20it%2C%20and%20leaves%20the%20rest%20for%20the%20notebooks%20that%20score%20variants%3A%20their%20cache%2C%20%60.altar%2F%60%2C%20and%0A%20%20%20%20their%20run%20directory%2C%20%60altar-tutorials%2F%60.%20The%20default%20is%20%60~%2F.cache%2Faltar%2Ftutorials%2Fseries%60%3B%20change%20it%20here%2C%20or%0A%20%20%20%20start%20the%20notebook%20with%20%60--%20--work-dir%20DIR%60.%0A%0A%20%20%20%20The%20identifiers%20below%20are%20the%20ones%20every%20notebook%20uses%3A%0A%0A%20%20%20%20-%20%60job_id%60%20names%20the%20files%20a%20run%20stages%20for%20itself.%20Reuse%20it%20across%20the%20series.%0A%20%20%20%20-%20%60genome_build%60%20is%20the%20assembly%20of%20the%20cohort's%20coordinates.%20A%20run%20checks%20that%20every%20source%20serves%20it.%0A%20%20%20%20-%20The%20three%20source%20names%20become%20the%20%60%5Bsources.%3Cname%3E%5D%60%20sections%20of%20the%20spec%20in%20Step%202.%20A%20name%20labels%20a%0A%20%20%20%20%20%20source%20within%20one%20run%3B%20change%20it%20only%20to%20keep%20two%20copies%20of%20one%20source%20apart.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20work_dir_input%20%3D%20mo.ui.text(%0A%20%20%20%20%20%20%20%20value%3Dseries.display_path(series.work_dir(mo.cli_args()))%2C%0A%20%20%20%20%20%20%20%20label%3D%22Series%20work%20directory%22%2C%0A%20%20%20%20%20%20%20%20full_width%3DTrue%2C%0A%20%20%20%20)%0A%20%20%20%20work_dir_input%0A%20%20%20%20return%20(work_dir_input%2C)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20job_id%20%3D%20series.JOB_ID%0A%20%20%20%20genome_build%20%3D%20series.GENOME_BUILD%0A%20%20%20%20gnomad_name%20%3D%20series.GNOMAD_SOURCE%0A%20%20%20%20clinvar_name%20%3D%20series.CLINVAR_SOURCE%0A%20%20%20%20phylop_name%20%3D%20series.PHYLOP_SOURCE%0A%20%20%20%20return%20clinvar_name%2C%20genome_build%2C%20gnomad_name%2C%20job_id%2C%20phylop_name%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(work_dir_input)%3A%0A%20%20%20%20series_dir%20%3D%20Path(work_dir_input.value).expanduser().resolve()%0A%20%20%20%20run_dir%20%3D%20series_dir%20%2F%20%22evidence%22%0A%20%20%20%20return%20(run_dir%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Step%201%3A%20choose%20variants%0A%0A%20%20%20%20A%20cohort%20is%20the%20set%20of%20variants%20a%20run%20looks%20at.%20Here%20it%20is%20a%20canonical%20variant%20TSV%3A%20a%20headerless%2C%0A%20%20%20%20tab-separated%20file%20with%20%60chromosome%60%2C%20one-based%20%60position%60%2C%20%60reference%60%2C%20%60alternate%60%2C%20and%20an%20optional%20label%20of%0A%20%20%20%20your%20own.%20For%20example%3A%0A%0A%20%20%20%20%60%60%60text%0A%20%20%20%20chr1%20%20%20%20109274968%20%20%20%20G%20%20%20%20T%20%20%20%201_109274968_G_T%0A%20%20%20%20%60%60%60%0A%0A%20%20%20%20%60load_variants()%60%20checks%20these%20fields%20and%20gives%20each%20row%20a%20variant%20ID%2C%20such%20as%20%60chr1%3A109274968%3AG%3AT%60.%20A%20variant%0A%20%20%20%20ID%20names%20one%20alternate%20allele%20at%20one%20position.%20Every%20source%20and%20model%20in%20Altar%20matches%20its%20values%20to%20a%20variant%0A%20%20%20%20by%20this%20ID.%0A%0A%20%20%20%20The%20included%20cohort%20holds%20five%20common%20variants%20from%20the%0A%20%20%20%20%5BOpen%20Targets%20Platform%5D(https%3A%2F%2Fplatform-docs.opentargets.org%2Fvariant)%3A%20rs12740374%20at%20the%20*CELSR2*%E2%80%93*SORT1*%0A%20%20%20%20locus%2C%20rs1260326%20in%20*GCKR*%2C%20rs7903146%20in%20*TCF7L2*%2C%20and%20rs429358%20and%20rs7412%20in%20*APOE*.%20Check%20that%20the%20table%0A%20%20%20%20holds%20the%20variants%20you%20intended%20and%20that%20their%20coordinates%20use%20GRCh38.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20variant_source%20%3D%20mo.ui.radio(%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Use%20the%20tutorial%20cohort%20(5%20Open%20Targets%20variants)%22%3A%20%22bundled%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Choose%20a%20canonical%20variant%20TSV%22%3A%20%22existing%22%2C%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20value%3D%22Use%20the%20tutorial%20cohort%20(5%20Open%20Targets%20variants)%22%2C%0A%20%20%20%20%20%20%20%20label%3D%22Variant%20input%22%2C%0A%20%20%20%20)%0A%20%20%20%20variant_path_input%20%3D%20mo.ui.text(%0A%20%20%20%20%20%20%20%20value%3Dseries.display_path(series.COHORT_TSV)%2C%0A%20%20%20%20%20%20%20%20label%3D%22TSV%20path%20(used%20when%20'Choose%20a%20canonical%20variant%20TSV'%20is%20selected)%22%2C%0A%20%20%20%20%20%20%20%20full_width%3DTrue%2C%0A%20%20%20%20)%0A%20%20%20%20mo.vstack(%5Bvariant_source%2C%20variant_path_input%5D)%0A%20%20%20%20return%20variant_path_input%2C%20variant_source%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo%2C%20variant_path_input%2C%20variant_source)%3A%0A%20%20%20%20if%20variant_source.value%20%3D%3D%20%22bundled%22%3A%0A%20%20%20%20%20%20%20%20if%20not%20series.COHORT_TSV.is_file()%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20raise%20FileNotFoundError(f%22the%20tutorial%20cohort%20is%20missing%20from%20this%20checkout%3A%20%7Bseries.COHORT_TSV%7D%22)%0A%20%20%20%20%20%20%20%20variant_tsv%20%3D%20series.COHORT_TSV%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20_typed%20%3D%20Path(variant_path_input.value).expanduser()%0A%20%20%20%20%20%20%20%20variant_tsv%20%3D%20(_typed%20if%20_typed.is_absolute()%20else%20series.REPOSITORY_ROOT%20%2F%20_typed).resolve()%0A%20%20%20%20%20%20%20%20mo.stop(%0A%20%20%20%20%20%20%20%20%20%20%20%20not%20variant_tsv.is_file()%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.callout(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20mo.md(f%22There%20is%20no%20file%20at%20%60%7Bseries.display_path(variant_tsv)%7D%60.%20Check%20the%20path%20in%20Step%201.%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20kind%3D%22danger%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20return%20(variant_tsv%2C)%0A%0A%0A%40app.cell%0Adef%20_(mo%2C%20variant_tsv)%3A%0A%20%20%20%20from%20altar.variants%20import%20load_variants%0A%0A%20%20%20%20variants%20%3D%20load_variants(str(variant_tsv))%0A%20%20%20%20mo.ui.table(variants%2C%20selection%3DNone)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Step%202%3A%20name%20the%20sources%0A%0A%20%20%20%20An%20annotation%20source%20is%20a%20dataset%20Altar%20looks%20variants%20up%20in%2C%20together%20with%20the%20installed%20code%20that%20reads%0A%20%20%20%20it.%20It%20runs%20no%20model%3A%20each%20value%20it%20returns%20already%20exists%20in%20the%20dataset.%20This%20tutorial%20uses%20three%2C%20each%0A%20%20%20%20installed%20by%20its%20own%20binding%2C%20the%20package%20that%20connects%20one%20dataset%20to%20Altar%3A%0A%0A%20%20%20%20-%20%5BgnomAD%5D(https%3A%2F%2Fkundajelab.github.io%2Faltar%2Fintegrations%2Fgnomad%2F)%20(%60altar-popfreq%60)%3A%20how%20common%20each%0A%20%20%20%20%20%20variant%20is%2C%20overall%20and%20per%20genetic%20ancestry%20group%3B%0A%20%20%20%20-%20%5BClinVar%5D(https%3A%2F%2Fkundajelab.github.io%2Faltar%2Fintegrations%2Fclinvar%2F)%20(%60altar-clinvar%60)%3A%20the%20clinical%0A%20%20%20%20%20%20classification%20submitters%20have%20given%20the%20variant%2C%20and%20how%20well%20it%20has%20been%20reviewed%3B%0A%20%20%20%20-%20%5BphyloP%20100-way%5D(https%3A%2F%2Fkundajelab.github.io%2Faltar%2Fintegrations%2Fphylop100way%2F)%20(%60altar-conservation%60)%3A%20how%0A%20%20%20%20%20%20conserved%20the%20variant's%20base%20is%20across%20100%20vertebrates.%0A%0A%20%20%20%20Each%20source%20reads%20a%20published%20copy%20of%20its%20dataset%20by%20default%3A%20a%20copy%20the%20Altar%20maintainers%20host%20in%20a%20public%0A%20%20%20%20bucket.%20A%20lookup%20reads%20only%20the%20parts%20of%20the%20copy%20its%20variants%20fall%20in%2C%20so%20nothing%20is%20downloaded%20in%20full.%0A%0A%20%20%20%20A%20run%20spec%20describes%20one%20run%3A%20its%20cohort%2C%20where%20it%20writes%2C%20and%20the%20sources%20and%20models%20it%20uses.%20The%20mapping%0A%20%20%20%20below%20is%20a%20run%20spec%20in%20Python.%20Each%20entry%20under%20%60sources%60%20names%20a%20source%20by%20its%20%60type%60.%20ClinVar's%20option%0A%20%20%20%20%60prioritize_pathogenic%60%20lets%20a%20reviewed%20pathogenic%20classification%20flag%20a%20variant%3B%20Step%206%20shows%20what%20that%0A%20%20%20%20means.%0A%0A%20%20%20%20%60work_dir%60%20is%20the%20run%20directory%2C%20where%20the%20run%20writes%20its%20export.%20Without%20it%2C%20%60altar%20run%60%20writes%20to%20a%0A%20%20%20%20directory%20named%20by%20the%20job%20ID%20in%20the%20directory%20it%20starts%20in%3B%20this%20spec%20names%20%60evidence%2F%60%20in%20the%20series%20work%0A%20%20%20%20directory%20instead%2C%20so%20that%20the%20scoring%20runs%20of%20the%20later%20tutorials%20keep%20their%20own.%20A%20run%20that%20scores%20no%20model%0A%20%20%20%20reuses%20nothing%2C%20so%20it%20writes%20no%20cache%20and%20needs%20no%20other%20directory.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20clinvar_name%2C%0A%20%20%20%20genome_build%2C%0A%20%20%20%20gnomad_name%2C%0A%20%20%20%20job_id%2C%0A%20%20%20%20phylop_name%2C%0A%20%20%20%20run_dir%2C%0A%20%20%20%20variant_tsv%2C%0A)%3A%0A%20%20%20%20spec%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%22run%22%3A%20%7B%22job_id%22%3A%20job_id%2C%20%22genome_build%22%3A%20genome_build%2C%20%22work_dir%22%3A%20str(run_dir)%7D%2C%0A%20%20%20%20%20%20%20%20%22variants%22%3A%20%7B%22path%22%3A%20str(variant_tsv)%7D%2C%0A%20%20%20%20%20%20%20%20%22sources%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20gnomad_name%3A%20%7B%22type%22%3A%20%22gnomad%22%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20clinvar_name%3A%20%7B%22type%22%3A%20%22clinvar%22%2C%20%22options%22%3A%20%7B%22prioritize_pathogenic%22%3A%20True%7D%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20phylop_name%3A%20%7B%22type%22%3A%20%22phylop100way%22%7D%2C%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%7D%0A%20%20%20%20return%20(spec%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo%2C%20spec)%3A%0A%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20The%20same%20spec%20as%20a%20TOML%20file%2C%20the%20form%20the%20%60altar%60%20command%20reads.%20Saved%20as%20%60annotate.toml%60%2C%20it%20runs%20with%0A%20%20%20%20%60altar%20run%20annotate.toml%60.%20Paths%20are%20shown%20relative%20to%20the%20repository%20or%20your%20home%20directory%3B%20the%20spec%0A%20%20%20%20holds%20full%20paths.%0A%0A%20%20%20%20%60%60%60toml%0A%20%20%20%20%7Bseries.spec_as_toml(spec)%7D%0A%20%20%20%20%60%60%60%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Step%203%3A%20check%20the%20spec%0A%0A%20%20%20%20%60validate()%60%20makes%20every%20check%20a%20run%20makes%20before%20it%20reads%20the%20cohort.%20It%20builds%20each%20source%2C%20which%20opens%0A%20%20%20%20its%20published%20copy%20over%20the%20network%2C%20and%20checks%20that%20the%20source%20serves%20the%20run's%20genome%20build.%20It%20confirms%0A%20%20%20%20that%20the%20cohort%20file%20exists%2C%20but%20reads%20no%20variant%20and%20writes%20no%20file.%20A%20problem%20raises%20%60RunSpecError%60%2C%20which%0A%20%20%20%20names%20the%20field%20to%20fix.%0A%0A%20%20%20%20%60validate()%60%20is%20%5BProvisional%5D(https%3A%2F%2Fkundajelab.github.io%2Faltar%2Freference%2Fmaturity%2F)%3A%20it%20works%20and%20is%0A%20%20%20%20documented%2C%20and%20its%20name%20or%20report%20is%20expected%20to%20change.%20The%20command-line%20form%20is%0A%20%20%20%20%60altar%20run%20--validate%20annotate.toml%60.%0A%0A%20%20%20%20Check%20that%20each%20source%20serves%20the%20release%20and%20genome%20build%20you%20expect.%20The%20release%20is%20part%20of%20a%20source's%0A%20%20%20%20identity%3A%20two%20releases%20of%20ClinVar%20are%20different%20data%2C%20and%20Altar%20keeps%20their%20values%20apart.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(spec)%3A%0A%20%20%20%20from%20altar.run%20import%20validate%0A%0A%20%20%20%20plan%20%3D%20validate(spec)%0A%20%20%20%20return%20(plan%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo%2C%20plan)%3A%0A%20%20%20%20_sources%20%3D%20pd.DataFrame(%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22section%22%3A%20f%22%5B%7Bsource.section%7D%5D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22source%22%3A%20source.name%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22release%22%3A%20(source.identity%20or%20%7B%7D).get(%22release%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22genome_build%22%3A%20(source.identity%20or%20%7B%7D).get(%22genome_build%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20source%20in%20plan.sources%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20)%0A%20%20%20%20mo.vstack(%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.ui.table(_sources%2C%20selection%3DNone)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f%22The%20run%20would%20read%20%60%7Bseries.display_path(plan.variants)%7D%60%2C%20look%20its%20variants%20up%20in%20these%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f%22%7Blen(plan.sources)%7D%20sources%2C%20and%20write%20a%20%7Bplan.export_format%7D%20export%20to%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f%22%60%7Bseries.display_path(plan.export_uri)%7D%60.%20A%20spec%20without%20models%20keeps%20no%20store%20file%3A%20the%20score%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f%22store%20is%20%60%7Bplan.store%7D%60.%22%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Step%204%3A%20run%20it%0A%0A%20%20%20%20%60run()%60%20does%20what%20%60altar%20run%60%20does.%20It%20reads%20the%20cohort%20and%20writes%20each%20variant%20in%20its%20standard%20form%2C%20looks%0A%20%20%20%20every%20variant%20up%20in%20every%20source%2C%20and%20writes%20one%20table%20with%20a%20row%20per%20variant.%20Press%20**Run%20the%20spec**%20to%0A%20%20%20%20start%20it.%20It%20takes%20a%20few%20seconds%20and%20writes%20only%20under%20the%20%60evidence%2F%60%20directory%20of%20the%20work%20directory.%20A%0A%20%20%20%20second%20run%20replaces%20the%20export.%0A%0A%20%20%20%20Each%20line%20of%20the%20log%20below%20is%20one%20stage%20of%20the%20run.%20A%20source's%20line%20names%20the%20release%20and%20genome%20build%20it%0A%20%20%20%20opened%20and%20where%20it%20read%20them%20from.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20run_button%20%3D%20mo.ui.run_button(label%3D%22Run%20the%20spec%22%2C%20kind%3D%22success%22)%0A%20%20%20%20run_button%0A%20%20%20%20return%20(run_button%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo%2C%20plan%2C%20run_button)%3A%0A%20%20%20%20%23%20The%20run%20follows%20the%20checked%20spec%3A%20a%20spec%20that%20fails%20Step%203%20stops%20here.%0A%20%20%20%20run_requested%20%3D%20plan%20is%20not%20None%20and%20(run_button.value%20or%20series.execute_requested(mo.cli_args()))%0A%20%20%20%20run_log%20%3D%20series.run_log()%0A%20%20%20%20run_log.clear()%0A%20%20%20%20return%20run_log%2C%20run_requested%0A%0A%0A%40app.cell%0Aasync%20def%20_(mo%2C%20run_requested%2C%20spec)%3A%0A%20%20%20%20from%20altar.run%20import%20run%0A%0A%20%20%20%20mo.stop(not%20run_requested%2C%20mo.md(%22Press%20**Run%20the%20spec**%20to%20run%20it.%22))%0A%20%20%20%20summary%20%3D%20await%20run(spec)%0A%20%20%20%20return%20(summary%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo%2C%20run_log%2C%20summary)%3A%0A%20%20%20%20mo.vstack(%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.callout(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20mo.md(f%22Wrote%20%7Bsummary.variant_count%7D%20variants%20to%20%60%7Bseries.display_path(summary.export_uri)%7D%60.%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20kind%3D%22success%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.md(%22%60%60%60text%5Cn%22%20%2B%20%22%5Cn%22.join(run_log.lines)%20%2B%20%22%5Cn%60%60%60%22)%2C%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Step%205%3A%20read%20the%20export%0A%0A%20%20%20%20The%20export%20is%20the%20table%20a%20run%20writes%3A%20one%20row%20per%20variant%2C%20sorted%20by%20variant%20ID.%20It%20is%20a%20Parquet%20directory%2C%0A%20%20%20%20which%20pandas%20reads%20in%20one%20call.%20Every%20source%20adds%20its%20own%20columns%2C%20each%20starting%20with%20the%20source's%20prefix%2C%0A%20%20%20%20such%20as%20%60gnomad_%60%20or%20%60clinvar_%60.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(summary)%3A%0A%20%20%20%20export%20%3D%20pd.read_parquet(summary.export_uri)%0A%20%20%20%20return%20(export%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(export%2C%20mo)%3A%0A%20%20%20%20_shown%20%3D%20%5B%0A%20%20%20%20%20%20%20%20%22variant_id%22%2C%0A%20%20%20%20%20%20%20%20%22gnomad_af%22%2C%0A%20%20%20%20%20%20%20%20%22gnomad_grpmax%22%2C%0A%20%20%20%20%20%20%20%20%22gnomad_af_grpmax%22%2C%0A%20%20%20%20%20%20%20%20%22clinvar_classification%22%2C%0A%20%20%20%20%20%20%20%20%22clinvar_review_stars%22%2C%0A%20%20%20%20%20%20%20%20%22phylop100way%22%2C%0A%20%20%20%20%5D%0A%20%20%20%20_frequencies%20%3D%20export%5B%22gnomad_af%22%5D.dropna()%0A%20%20%20%20_with_clinvar%20%3D%20int(export%5B%22clinvar_variation_id%22%5D.notna().sum())%0A%20%20%20%20_phylop%20%3D%20export%5B%22phylop100way%22%5D.dropna()%0A%20%20%20%20_observed%20%3D%20(%0A%20%20%20%20%20%20%20%20f%22In%20this%20cohort%2C%20gnomAD%20frequencies%20run%20from%20%7B_frequencies.min()%3A.3f%7D%20to%20%7B_frequencies.max()%3A.3f%7D%2C%20%22%0A%20%20%20%20%20%20%20%20f%22ClinVar%20has%20a%20record%20of%20%7B_with_clinvar%7D%20of%20the%20%7Blen(export)%7D%20variants%2C%20and%20phyloP%20scores%20run%20from%20%22%0A%20%20%20%20%20%20%20%20f%22%7B_phylop.min()%3A.3f%7D%20to%20%7B_phylop.max()%3A.3f%7D.%22%0A%20%20%20%20%20%20%20%20if%20len(_frequencies)%20and%20len(_phylop)%0A%20%20%20%20%20%20%20%20else%20%22%22%0A%20%20%20%20)%0A%20%20%20%20mo.vstack(%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.ui.table(export%5B%5Bcolumn%20for%20column%20in%20_shown%20if%20column%20in%20export.columns%5D%5D%2C%20selection%3DNone)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20The%20export%20has%20%7Blen(export.columns)%7D%20columns.%20These%20are%20the%20ones%20to%20read%20first%3A%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20-%20**%60gnomad_af%60**%20is%20the%20fraction%20of%20alleles%20in%20gnomAD's%2076%2C000%20genomes%20that%20carry%20the%20alternate%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20allele%2C%20from%200%20to%201.%0A%20%20%20%20%20%20%20%20%20%20%20%20-%20**%60gnomad_grpmax%60**%20and%20**%60gnomad_af_grpmax%60**%20name%20the%20genetic%20ancestry%20group%20where%20the%20allele%20is%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20most%20common%2C%20and%20its%20frequency%20there.%0A%20%20%20%20%20%20%20%20%20%20%20%20-%20**%60clinvar_classification%60**%20is%20ClinVar's%20germline%20classification%2C%20spelled%20as%20ClinVar%20writes%20it.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20**%60clinvar_review_stars%60**%20runs%20from%200%20to%204%3A%200%20means%20no%20assertion%20criteria%20were%20given%2C%20and%203%20means%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20an%20expert%20panel%20reviewed%20the%20classification.%0A%20%20%20%20%20%20%20%20%20%20%20%20-%20**%60phylop100way%60**%20is%20a%20signed%20score%20at%20the%20variant's%20base%2C%20from%20about%20-20%20to%2010.%20It%20is%20positive%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20where%20the%20base%20has%20changed%20more%20slowly%20than%20expected%20across%20100%20vertebrates%20(conserved)%20and%20negative%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20where%20it%20has%20changed%20faster.%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B_observed%7D%20These%20are%20common%20variants%20found%20in%20genome-wide%20association%20studies.%20ClinVar%20describes%0A%20%20%20%20%20%20%20%20%20%20%20%20them%20as%20risk%20factors%2C%20associations%2C%20drug%20responses%2C%20benign%20or%20conflicting%2C%20not%20as%20pathogenic.%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20An%20empty%20value%20means%20the%20source%20holds%20no%20record%20for%20that%20variant.%20It%20is%20not%20a%20zero%2C%20and%20it%20is%20not%0A%20%20%20%20%20%20%20%20%20%20%20%20evidence%20that%20a%20variant%20is%20rare%20or%20benign.%20A%20source%20that%20has%20a%20record%20can%20still%20leave%20one%20field%20of%20it%0A%20%20%20%20%20%20%20%20%20%20%20%20empty%2C%20such%20as%20%60clinvar_oncogenicity%60%20for%20a%20variant%20ClinVar%20has%20not%20classified%20for%20cancer.%20Step%208%0A%20%20%20%20%20%20%20%20%20%20%20%20looks%20up%20a%20variant%20that%20gnomAD%20and%20ClinVar%20have%20no%20record%20of.%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%22%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.accordion(%7Bf%22All%20%7Blen(export.columns)%7D%20columns%22%3A%20mo.ui.table(export%2C%20selection%3DNone)%7D)%2C%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Step%206%3A%20see%20why%20a%20variant%20is%20prioritized%0A%0A%20%20%20%20A%20source%20or%20a%20model%20can%20declare%20a%20prioritization%20rule%3A%20a%20condition%20over%20its%20columns%20that%20flags%20a%20variant%0A%20%20%20%20for%20a%20closer%20look.%20Every%20row%20of%20the%20export%20records%20the%20result%20in%20three%20columns%3A%0A%0A%20%20%20%20-%20%60prioritized%60%20is%20true%20when%20at%20least%20one%20rule%20matched%3B%0A%20%20%20%20-%20%60prioritized_source_names%60%20lists%20the%20sources%20whose%20rule%20matched%3B%20and%0A%20%20%20%20-%20%60prioritized_model_ids%60%20lists%20the%20models%20whose%20rule%20matched.%20This%20run%20has%20no%20models.%0A%0A%20%20%20%20gnomAD%20and%20phyloP%20declare%20no%20rule.%20ClinVar's%20rule%20is%20off%20unless%20%60prioritize_pathogenic%60%20is%20set%2C%20as%20Step%202%0A%20%20%20%20set%20it.%20The%20ClinVar%20binding%20names%20the%20rule%20%60PATHOGENIC_PREDICATE%60.%20A%20rule%20has%20three%20outcomes%3A%20true%2C%20false%2C%0A%20%20%20%20or%20unknown%20when%20a%20value%20it%20reads%20is%20missing.%20Only%20true%20flags%20a%20variant.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(export)%3A%0A%20%20%20%20from%20altar_clinvar%20import%20PATHOGENIC_PREDICATE%0A%0A%20%20%20%20rule_sql%20%3D%20PATHOGENIC_PREDICATE.to_sql()%0A%20%20%20%20reasons%20%3D%20export%5B%0A%20%20%20%20%20%20%20%20%5B%22variant_id%22%2C%20%22prioritized%22%2C%20%22prioritized_source_names%22%2C%20%22clinvar_pathogenic%22%2C%20%22clinvar_review_stars%22%5D%0A%20%20%20%20%5D%0A%20%20%20%20return%20PATHOGENIC_PREDICATE%2C%20reasons%2C%20rule_sql%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(PATHOGENIC_PREDICATE%2C%20export%2C%20mo%2C%20reasons%2C%20rule_sql)%3A%0A%20%20%20%20_records%20%3D%20export.astype(object).where(export.notna()%2C%20None).to_dict(%22records%22)%0A%20%20%20%20_outcomes%20%3D%20%7BTrue%3A%20%22true%22%2C%20False%3A%20%22false%22%2C%20None%3A%20%22unknown%22%7D%0A%20%20%20%20_table%20%3D%20reasons.assign(%0A%20%20%20%20%20%20%20%20prioritized_source_names%3D%5Bjson.dumps(list(names))%20for%20names%20in%20reasons%5B%22prioritized_source_names%22%5D%5D%2C%0A%20%20%20%20%20%20%20%20clinvar_rule%3D%5B_outcomes%5BPATHOGENIC_PREDICATE.evaluate(record)%5D%20for%20record%20in%20_records%5D%2C%0A%20%20%20%20)%0A%20%20%20%20_flagged%20%3D%20int(export%5B%22prioritized%22%5D.sum())%0A%20%20%20%20mo.vstack(%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.md(f%22ClinVar's%20rule%2C%20written%20as%20SQL%3A%20%60%7Brule_sql%7D%60%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.ui.table(_table%2C%20selection%3DNone)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f%22%7B_flagged%7D%20of%20the%20%7Blen(export)%7D%20variants%20are%20prioritized.%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2B%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22The%20rule%20needs%20a%20pathogenic%20or%20likely%20pathogenic%20classification%20with%20at%20least%20one%20review%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22star%2C%20and%20none%20of%20these%20variants%20has%20one%2C%20so%20every%20%60prioritized_source_names%60%20list%20is%20empty.%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20_flagged%20%3D%3D%200%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%20%22The%20%60prioritized_source_names%60%20list%20of%20each%20flagged%20variant%20names%20the%20source%20whose%20rule%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22matched.%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2B%20%22%20When%20you%20show%20a%20prioritized%20variant%2C%20show%20these%20lists%2C%20not%20only%20the%20flag.%20A%20match%20means%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22the%20source's%20declared%20rule%20held.%20It%20is%20a%20workflow%20default%2C%20not%20a%20calibrated%20clinical%20or%20causal%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22threshold%3B%20see%20%5Bwhat%20%E2%80%9Cprioritized%E2%80%9D%20means%5D(https%3A%2F%2Fkundajelab.github.io%2Faltar%2Fscience%2Fprioritization%2F).%22%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Step%207%3A%20read%20the%20provenance%0A%0A%20%20%20%20The%20export%20directory%20also%20holds%20%60_run_summary.json%60%2C%20the%20same%20summary%20%60run()%60%20returned.%20It%20records%20what%20the%0A%20%20%20%20run%20read%2C%20so%20a%20shared%20export%20still%20says%20where%20its%20columns%20came%20from%3A%0A%0A%20%20%20%20-%20%60sources%60%20names%20the%20release%20and%20genome%20build%20each%20source%20served%3B%0A%20%20%20%20-%20%60potential_misses%60%20counts%20variants%20a%20lookup%20may%20have%20missed%2C%20such%20as%20an%20indel%20written%20in%20a%20form%20the%0A%20%20%20%20%20%20datasets%20do%20not%20use.%20This%20cohort%20has%20only%20SNVs%2C%20so%20it%20is%20empty%3B%0A%20%20%20%20-%20%60provenance%60%20repeats%20each%20source's%20identity%2C%20and%20records%20each%20model's%20settings%20when%20the%20run%20has%20models.%0A%0A%20%20%20%20%5BRead%20a%20run's%20results%5D(https%3A%2F%2Fkundajelab.github.io%2Faltar%2Fguides%2Fresults%2F%23read-its-provenance)%20describes%0A%20%20%20%20every%20field.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(summary)%3A%0A%20%20%20%20run_summary%20%3D%20json.loads((Path(summary.export_uri)%20%2F%20%22_run_summary.json%22).read_text())%0A%20%20%20%20return%20(run_summary%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo%2C%20run_summary)%3A%0A%20%20%20%20_served%20%3D%20pd.DataFrame(%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22source%22%3A%20source%5B%22name%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22release%22%3A%20(source%5B%22identity%22%5D%20or%20%7B%7D).get(%22release%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22genome_build%22%3A%20(source%5B%22identity%22%5D%20or%20%7B%7D).get(%22genome_build%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22contract%22%3A%20(source%5B%22identity%22%5D%20or%20%7B%7D).get(%22source_id%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20source%20in%20run_summary%5B%22sources%22%5D%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20)%0A%20%20%20%20mo.vstack(%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.ui.table(_served%2C%20selection%3DNone)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f%22%60variant_count%60%20is%20%7Brun_summary%5B'variant_count'%5D%7D%2C%20%60potential_misses%60%20has%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f%22%7Blen(run_summary%5B'potential_misses'%5D)%7D%20entries%2C%20and%20%60dropped_alleles%60%20has%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f%22%7Blen(run_summary%5B'dropped_alleles'%5D)%7D.%22%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.accordion(%7B%22The%20whole%20summary%22%3A%20mo.json(json.loads(series.display_text(json.dumps(run_summary))))%7D)%2C%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Step%208%3A%20look%20variants%20up%20from%20Python%0A%0A%20%20%20%20A%20run%20looks%20variants%20up%20for%20a%20whole%20cohort.%20To%20look%20up%20a%20few%20variants%20directly%2C%20build%20each%20source%20with%0A%20%20%20%20%60from_options()%60%2C%20which%20takes%20the%20same%20options%20as%20a%20spec's%20%60options%60%2C%20and%20pass%20them%20to%0A%20%20%20%20%60fetch_annotations()%60.%20The%20registry%20finds%20an%20installed%20source%20by%20its%20%60type%60.%20A%20source%20built%20in%20code%20is%20yours%0A%20%20%20%20to%20close%2C%20so%20the%20cell%20opens%20each%20one%20in%20a%20%60with%60%20block.%0A%0A%20%20%20%20%60fetch_annotations()%60%20returns%20an%20entry%20for%20every%20variant%20ID%20you%20pass.%20A%20source%20with%20no%20record%20of%20a%20variant%0A%20%20%20%20adds%20no%20columns%20to%20its%20entry%3A%20a%20miss%20is%20an%20absent%20key%2C%20never%20a%20zero.%0A%0A%20%20%20%20The%20three%20default%20IDs%20show%20three%20cases%3A%0A%0A%20%20%20%20-%20%60chr19%3A44908822%3AC%3AT%60%20is%20rs7412%20from%20the%20cohort%3B%0A%20%20%20%20-%20%60chr19%3A44908822%3AC%3AA%60%20is%20a%20different%20alternate%20allele%20at%20the%20same%20base.%20gnomAD%20and%20ClinVar%20key%20their%20records%0A%20%20%20%20%20%20by%20allele%20and%20hold%20none%20for%20it.%20phyloP%20scores%20the%20base%2C%20so%20it%20still%20answers%3B%0A%20%20%20%20-%20%60chr17%3A43045712%3AT%3AC%60%20is%20a%20*BRCA1*%20variant%20ClinVar%20classifies%20as%20pathogenic%2C%20with%20two%20review%20stars.%0A%0A%20%20%20%20Replace%20them%20with%20IDs%20of%20your%20own%2C%20written%20as%20%60chr%3Apos%3Aref%3Aalt%60.%20Write%20an%20indel%20in%20its%20left-aligned%20form%3B%0A%20%20%20%20%5BBuild%20and%20check%20variant%20IDs%5D(https%3A%2F%2Fkundajelab.github.io%2Faltar%2Fpython%2Fvariants%2F%23build-and-check-variant-ids)%0A%20%20%20%20shows%20how.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20lookup_input%20%3D%20mo.ui.text(%0A%20%20%20%20%20%20%20%20value%3D%22chr19%3A44908822%3AC%3AT%2C%20chr19%3A44908822%3AC%3AA%2C%20chr17%3A43045712%3AT%3AC%22%2C%0A%20%20%20%20%20%20%20%20label%3D%22Variant%20IDs%2C%20separated%20by%20commas%22%2C%0A%20%20%20%20%20%20%20%20full_width%3DTrue%2C%0A%20%20%20%20)%0A%20%20%20%20lookup_input%0A%20%20%20%20return%20(lookup_input%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(lookup_input%2C%20mo)%3A%0A%20%20%20%20from%20altar.variants%20import%20VariantIdentityError%2C%20VariantKey%0A%0A%20%20%20%20_typed%20%3D%20%5Bitem.strip()%20for%20item%20in%20lookup_input.value.split(%22%2C%22)%20if%20item.strip()%5D%0A%20%20%20%20mo.stop(not%20_typed%2C%20mo.callout(%22Enter%20at%20least%20one%20variant%20ID.%22%2C%20kind%3D%22warn%22))%0A%20%20%20%20try%3A%0A%20%20%20%20%20%20%20%20lookup_ids%20%3D%20%5BVariantKey.require_canonical(item).variant_id%20for%20item%20in%20_typed%5D%0A%20%20%20%20except%20VariantIdentityError%20as%20_error%3A%0A%20%20%20%20%20%20%20%20mo.stop(True%2C%20mo.callout(mo.md(f%22That%20is%20not%20a%20variant%20ID%20Altar%20reads%3A%20%7B_error%7D%22)%2C%20kind%3D%22danger%22))%0A%20%20%20%20return%20(lookup_ids%2C)%0A%0A%0A%40app.cell%0Aasync%20def%20_(lookup_ids)%3A%0A%20%20%20%20from%20altar.sources%20import%20fetch_annotations%2C%20get_annotation_source_registry%0A%0A%20%20%20%20registry%20%3D%20get_annotation_source_registry()%0A%20%20%20%20with%20(%0A%20%20%20%20%20%20%20%20registry.get(%22gnomad%22).from_options()%20as%20gnomad%2C%0A%20%20%20%20%20%20%20%20registry.get(%22clinvar%22).from_options(prioritize_pathogenic%3DTrue)%20as%20clinvar%2C%0A%20%20%20%20%20%20%20%20registry.get(%22phylop100way%22).from_options()%20as%20phylop%2C%0A%20%20%20%20)%3A%0A%20%20%20%20%20%20%20%20looked_up%20%3D%20await%20fetch_annotations(%5Bgnomad%2C%20clinvar%2C%20phylop%5D%2C%20lookup_ids)%0A%20%20%20%20%20%20%20%20clinvar_rule%20%3D%20clinvar.prioritize_predicate()%0A%20%20%20%20return%20clinvar_rule%2C%20looked_up%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(clinvar_rule%2C%20looked_up%2C%20mo)%3A%0A%20%20%20%20_outcomes%20%3D%20%7BTrue%3A%20%22true%22%2C%20False%3A%20%22false%22%2C%20None%3A%20%22unknown%22%7D%0A%20%20%20%20_rows%20%3D%20%5B%5D%0A%20%20%20%20for%20_variant_id%2C%20_columns%20in%20looked_up.items()%3A%0A%20%20%20%20%20%20%20%20_gnomad%20%3D%20%5Bname%20for%20name%20in%20_columns%20if%20name.startswith(%22gnomad_%22)%5D%0A%20%20%20%20%20%20%20%20_clinvar%20%3D%20%5Bname%20for%20name%20in%20_columns%20if%20name.startswith(%22clinvar_%22)%5D%0A%20%20%20%20%20%20%20%20_rows.append(%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22variant_id%22%3A%20_variant_id%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22gnomad%22%3A%20f%22%7Blen(_gnomad)%7D%20columns%22%20if%20_gnomad%20else%20%22absent%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22gnomad_af%22%3A%20_columns.get(%22gnomad_af%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22clinvar%22%3A%20f%22%7Blen(_clinvar)%7D%20columns%22%20if%20_clinvar%20else%20%22absent%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22clinvar_classification%22%3A%20_columns.get(%22clinvar_classification%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22phylop100way%22%3A%20_columns.get(%22phylop100way%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22clinvar_rule%22%3A%20_outcomes%5Bclinvar_rule.evaluate(_columns)%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20mo.vstack(%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.ui.table(pd.DataFrame(_rows)%2C%20selection%3DNone)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Where%20ClinVar%20has%20no%20record%2C%20the%20rule%20reads%20a%20missing%20value%20and%20its%20outcome%20is%20unknown%2C%20not%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22false.%20An%20unknown%20outcome%20does%20not%20flag%20a%20variant%2C%20but%20it%20says%20something%20different%3A%20the%20rule%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22never%20saw%20a%20classification.%22%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.accordion(%7B%22What%20fetch_annotations%20returned%22%3A%20mo.json(looked_up)%7D)%2C%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Review%20the%20workflow%0A%0A%20%20%20%20The%20path%20through%20Altar%20was%3A%0A%0A%20%20%20%20%60variant%20TSV%20%E2%86%92%20run%20spec%20%E2%86%92%20validate%20%E2%86%92%20run%20%E2%86%92%20export%20and%20_run_summary.json%60%0A%0A%20%20%20%20and%2C%20from%20Python%2C%20%60from_options()%20%E2%86%92%20fetch_annotations()%60%20for%20a%20few%20variants%20at%20a%20time.%0A%0A%20%20%20%20Run%20the%20notebook%20again%20with%20the%20same%20settings%3A%20the%20run%20replaces%20its%20export%20with%20the%20same%20rows.%20Then%20choose%0A%20%20%20%20your%20own%20TSV%20in%20Step%201%2C%20or%20add%20a%20source%20to%20the%20spec%20in%20Step%202.%20%60altar%20sources%60%20lists%20the%20installed%20sources%2C%0A%20%20%20%20and%20%5BAnnotate%20variants%20with%20evidence%5D(https%3A%2F%2Fkundajelab.github.io%2Faltar%2Fguides%2Fannotate%2F)%20adds%20Open%20Targets%0A%20%20%20%20enhancer-to-gene%20links%20and%20the%20others.%0A%0A%20%20%20%20Next%3A%0A%0A%20%20%20%20-%20%5BTutorial%201%5D(https%3A%2F%2Fkundajelab.github.io%2Faltar%2Fstart%2Fnotebooks%2F01_score_with_cherimoya.html)%0A%20%20%20%20%20%20scores%20the%20same%20five%20variants%20with%20the%20Cherimoya%20model.%20It%20needs%20Docker%2C%20and%20runs%20on%20an%20NVIDIA%20GPU%20or%0A%20%20%20%20%20%20the%20CPU.%0A%20%20%20%20-%20%5BUse%20Altar%20from%20Python%5D(https%3A%2F%2Fkundajelab.github.io%2Faltar%2Fpython%2F%23look-up-evidence)%20covers%0A%20%20%20%20%20%20%60fetch_annotations()%60%20and%20%60run()%60%20in%20scripts.%0A%20%20%20%20-%20%5BRead%20a%20run's%20results%5D(https%3A%2F%2Fkundajelab.github.io%2Faltar%2Fguides%2Fresults%2F)%20covers%20the%20export%20and%20its%0A%20%20%20%20%20%20provenance.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
e3adeb5dd8397e39c24adddff93b1892