-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,513 additions
and
151 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<script setup lang="ts"> | ||
import { computed } from 'vue' | ||
import VegaPlot from '@/components/VegaPlot.vue' | ||
const coarseClinsigLabels = ['benign', 'uncertain', 'pathogenic'] | ||
const bucketLabels = [ | ||
'no frequency', | ||
'<0.00001', | ||
'<0.00025', | ||
'<0.0005', | ||
'<0.0001', | ||
'<0.00025', | ||
'<0.0005', | ||
'<0.001', | ||
'<0.0025', | ||
'<0.005', | ||
'<0.01', | ||
'<0.025', | ||
'<0.05', | ||
'<0.1', | ||
'<0.25', | ||
'<0.5', | ||
'<1.0' | ||
] | ||
export interface CountsRecord { | ||
/** Coarse clinical significance ID */ | ||
coarse_clinsig: number | ||
/** Counts per bucket */ | ||
counts: number[] | ||
} | ||
export interface Props { | ||
/** Gene symbol */ | ||
geneSymbol: string | ||
/** Expression records */ | ||
perFreqCounts: CountsRecord[] | ||
} | ||
const props = withDefaults(defineProps<Props>(), {}) | ||
const vegaData = computed(() => { | ||
const values = [] | ||
for (const record of props?.perFreqCounts || []) { | ||
for (let i = 0; i < record.counts.length; i++) { | ||
if (record.counts[i] > 0) { | ||
values.push({ | ||
coarseClinsig: coarseClinsigLabels[record.coarse_clinsig], | ||
coarseClinsigNo: record.coarse_clinsig, | ||
freqBucket: bucketLabels[i], | ||
freqBucketNo: i, | ||
value: record.counts[i] | ||
}) | ||
} | ||
} | ||
} | ||
if (values.length) { | ||
return values | ||
} else { | ||
return null | ||
} | ||
}) | ||
const vegaLayer = [ | ||
{ | ||
mark: { type: 'bar', tooltip: true } | ||
}, | ||
{ | ||
mark: { | ||
type: 'text', | ||
align: 'center', | ||
baseline: 'middle', | ||
dy: -10 | ||
}, | ||
encoding: { | ||
text: { field: 'value', type: 'quantitative', fontSize: 8 } | ||
} | ||
} | ||
] | ||
const vegaEncoding = { | ||
x: { | ||
field: 'freqBucket', | ||
title: 'population frequency', | ||
type: 'nominal', | ||
sort: bucketLabels, | ||
axis: { labelAngle: 45 } | ||
}, | ||
y: { | ||
field: 'value', | ||
scale: { type: 'log' }, | ||
title: 'variant count', | ||
axis: { | ||
grid: false, | ||
tickExtra: false | ||
} | ||
}, | ||
xOffset: { | ||
field: 'coarseClinsig', | ||
type: 'nominal', | ||
sort: coarseClinsigLabels | ||
}, | ||
color: { | ||
field: 'coarseClinsig', | ||
title: 'clinical sig.', | ||
type: 'nominal', | ||
sort: coarseClinsigLabels, | ||
scale: { | ||
domain: coarseClinsigLabels, | ||
range: ['#5d9936', '#f5c964', '#b05454'] | ||
} | ||
} | ||
} | ||
/** Ref to the VegaPlot (for testing). */ | ||
// const vegaPlotRef = ref(null) | ||
</script> | ||
|
||
<template> | ||
<figure class="figure border rounded pl-2 pt-2 mr-3 w-100 col"> | ||
<figcaption class="figure-caption text-center"> | ||
Population frequency of ClinVar variants | ||
</figcaption> | ||
<VegaPlot | ||
:data-values="vegaData" | ||
:encoding="vegaEncoding" | ||
:mark="false" | ||
:layer="vegaLayer" | ||
:width="800" | ||
:height="300" | ||
renderer="svg" | ||
/> | ||
</figure> | ||
</template> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
<script setup lang="ts"> | ||
import { computed } from 'vue' | ||
import VegaPlot from '@/components/VegaPlot.vue' | ||
export interface ExpressionRecord { | ||
/** Tissue id */ | ||
tissue: number | ||
/** Detailed tissue id */ | ||
tissue_detailed: number | ||
/** TPM quantiles (0, 0.25, 0.5, 0.75, 1.0) */ | ||
tpms: number[] | ||
} | ||
export interface Props { | ||
/** Gene symbol */ | ||
geneSymbol: string | ||
/** Expression records */ | ||
expressionRecords: ExpressionRecord[] | ||
} | ||
const props = withDefaults(defineProps<Props>(), {}) | ||
const tissueLabels = [ | ||
'Adipose Tissue', | ||
'Adrenal Gland', | ||
'Bladder', | ||
'Blood', | ||
'Blood Vessel', | ||
'Bone Marrow', | ||
'Brain', | ||
'Breast', | ||
'Cervix Uteri', | ||
'Colon', | ||
'Esophagus', | ||
'Fallopian Tube', | ||
'Heart', | ||
'Kidney', | ||
'Liver', | ||
'Lung', | ||
'Muscle', | ||
'Nerve', | ||
'Ovary', | ||
'Pancreas', | ||
'Pituitary', | ||
'Prostate', | ||
'Salivary Gland', | ||
'Skin', | ||
'Small Intestine', | ||
'Spleen', | ||
'Stomach', | ||
'Testis', | ||
'Thyroid', | ||
'Uterus', | ||
'Vagina' | ||
] | ||
const tissueDetailedLabels = [ | ||
'Adipose - Subcutaneous', | ||
'Adipose - Visceral (Omentum)', | ||
'Adrenal Gland', | ||
'Artery - Aorta', | ||
'Artery - Coronary', | ||
'Artery - Tibial', | ||
'Bladder', | ||
'Brain - Amygdala', | ||
'Brain - Anterior cingulate cortex (BA24)', | ||
'Brain - Caudate (basal ganglia)', | ||
'Brain - Cerebellar Hemisphere', | ||
'Brain - Cerebellum', | ||
'Brain - Cortex', | ||
'Brain - Frontal Cortex (BA9)', | ||
'Brain - Hippocampus', | ||
'Brain - Hypothalamus', | ||
'Brain - Nucleus accumbens (basal ganglia)', | ||
'Brain - Putamen (basal ganglia)', | ||
'Brain - Spinal cord (cervical c-1)', | ||
'Brain - Substantia nigra', | ||
'Breast - Mammary Tissue', | ||
'Cells - Cultured fibroblasts', | ||
'Cells - EBV-transformed lymphocytes', | ||
'Cells - Leukemia cell line (CML)', | ||
'Cervix - Ectocervix', | ||
'Cervix - Endocervix', | ||
'Colon - Sigmoid', | ||
'Colon - Transverse', | ||
'Esophagus - Gastroesophageal Junction', | ||
'Esophagus - Mucosa', | ||
'Esophagus - Muscularis', | ||
'Fallopian Tube', | ||
'Heart - Atrial Appendage', | ||
'Heart - Left Ventricle', | ||
'Kidney - Cortex', | ||
'Kidney - Medulla', | ||
'Liver', | ||
'Lung', | ||
'Minor Salivary Gland', | ||
'Muscle - Skeletal', | ||
'Nerve - Tibial', | ||
'Ovary', | ||
'Pancreas', | ||
'Pituitary', | ||
'Prostate', | ||
'Salivary Gland', | ||
'Skin - Not Sun Exposed (Suprapubic)', | ||
'Skin - Sun Exposed (Lower leg)', | ||
'Small Intestine - Terminal Ileum', | ||
'Spleen', | ||
'Stomach', | ||
'Testis', | ||
'Thyroid', | ||
'Uterus', | ||
'Vagina', | ||
'Whole Blood' | ||
] | ||
const vegaData = computed(() => { | ||
return props?.expressionRecords?.map((record) => ({ | ||
tissue: tissueLabels[record.tissue], | ||
tissueDetailed: tissueDetailedLabels[record.tissue_detailed], | ||
lower: record.tpms[0], | ||
q1: record.tpms[1], | ||
median: record.tpms[2], | ||
q3: record.tpms[3], | ||
upper: record.tpms[4] | ||
})) | ||
}) | ||
const vegaEncoding = { | ||
x: { | ||
field: 'tissueDetailed', | ||
type: 'nominal', | ||
title: null, | ||
axis: { labelAngle: 45 } | ||
} | ||
} | ||
const vegaLayer = [ | ||
{ | ||
mark: { type: 'rule', tooltip: { content: 'data' } }, | ||
encoding: { | ||
y: { | ||
field: 'lower', | ||
type: 'quantitative', | ||
scale: { zero: false }, | ||
title: 'TPM' | ||
}, | ||
y2: { field: 'upper' } | ||
} | ||
}, | ||
{ | ||
mark: { type: 'bar', size: 14, tooltip: { content: 'data' } }, | ||
encoding: { | ||
y: { field: 'q1', type: 'quantitative' }, | ||
y2: { field: 'q3' }, | ||
color: { field: 'tissue', type: 'nominal', legend: null } | ||
} | ||
}, | ||
{ | ||
mark: { | ||
type: 'tick', | ||
color: 'white', | ||
size: 14, | ||
tooltip: { content: 'data' } | ||
}, | ||
encoding: { | ||
y: { field: 'median', type: 'quantitative' } | ||
} | ||
} | ||
] | ||
</script> | ||
|
||
<template> | ||
<figure class="figure border rounded pl-2 pt-2 mr-3 w-100 col"> | ||
<figcaption class="figure-caption text-center"> | ||
Bulk tissue gene expression for gene {{ props.geneSymbol }} | ||
</figcaption> | ||
<VegaPlot | ||
:data-values="vegaData" | ||
:encoding="vegaEncoding" | ||
:layer="vegaLayer" | ||
:mark="false" | ||
:width="1000" | ||
:height="300" | ||
renderer="svg" | ||
/> | ||
</figure> | ||
</template> |
Oops, something went wrong.