Unverified Commit 3da4c438 authored by Jyothish's avatar Jyothish Committed by GitHub
Browse files

New stats for all species (#485)

* New compara and variation stats;
parent a254a23c
Pipeline #152008 passed with stages
in 5 minutes and 31 seconds
......@@ -54,44 +54,41 @@
padding: 6px 20px;
grid-template-columns: [title] 120px [first_summary_stat] 250px [second_summary_stat] auto [example-link] 150px;
align-items: center;
min-height: 50px;
.title {
grid-column: title;
color: $medium-dark-grey;
color: $black;
font-weight: $light;
}
.summaryStat {
grid-column: first_summary_stat;
.value {
font-size: 26px;
font-size: 24px;
}
.unit {
color: $dark-grey;
padding-left: 5px;
color: $black;
padding: 0 6px;
font-weight: $light;
}
}
.summaryStat + .summaryStat {
grid-column: second_summary_stat;
.value {
font-size: 22px;
}
.unit {
color: $dark-grey;
padding-left: 5px;
}
}
.exampleLink {
grid-column: example-link;
}
}
.questionButton {
top: 2px;
position: relative;
}
}
.statsGroup {
padding: 16px 20px 0;
......@@ -100,7 +97,8 @@
.title {
grid-column: title;
color: $medium-dark-grey;
color: $black;
font-weight: $light;
}
.stats {
......@@ -116,3 +114,8 @@
}
}
.noData {
color: $black;
font-weight: $light;
}
......@@ -21,6 +21,7 @@ import classNames from 'classnames';
import ViewInAppPopup from 'src/shared/components/view-in-app-popup/ViewInAppPopup';
import SpeciesStats from 'src/content/app/species/components/species-stats/SpeciesStats';
import ExpandableSection from 'src/shared/components/expandable-section/ExpandableSection';
import QuestionButton from 'src/shared/components/question-button/QuestionButton';
import {
getActiveGenomeId,
......@@ -81,21 +82,28 @@ type ContentProps = {
const getCollapsedContent = (props: ContentProps) => {
const { species, statsSection } = props;
const { summaryStats, section, exampleLinks } = statsSection;
const { title, exampleLinkText } = sectionGroupsMap[section];
const { title, helpText, exampleLinkText } = sectionGroupsMap[section];
return (
<div className={styles.collapsedContent}>
<span className={styles.title}>{title}</span>
{summaryStats?.length &&
{summaryStats?.length ? (
summaryStats.map((summaryStat, index) => {
return (
<div className={styles.summaryStat} key={index}>
<span className={styles.value}>{summaryStat.primaryValue}</span>
<span className={styles.unit}>{summaryStat.primaryUnit}</span>
{helpText && (
<span className={styles.questionButton}>
<QuestionButton helpText={helpText} />
</span>
)}
</div>
);
})}
})
) : (
<div className={styles.noData}>no data</div>
)}
{exampleLinks && species.isEnabled && (
<ExampleLinkWithPopup links={exampleLinks}>
......@@ -192,6 +200,7 @@ const SpeciesMainViewStats = (props: Props) => {
key={key}
collapsedContent={getCollapsedContent(contentProps)}
expandedContent={
contentProps.statsSection.summaryStats?.length &&
contentProps.statsSection.groups
? getExpandedContent(contentProps)
: null
......
......@@ -10,15 +10,22 @@ $secondary-text-color: $dark-grey;
}
.preLabel {
color: $secondary-text-color;
color: $black;
padding-right: 4px;
font-weight: $light;
}
.preLabel + .label {
margin-top: -3px;
}
.questionButton {
top: 2px;
position: relative;
}
.primaryValue {
font-size: 26px;
font-size: 24px;
padding-left: 30px;
}
.primaryUnit {
......
......@@ -17,11 +17,14 @@
import React from 'react';
import classNames from 'classnames';
import QuestionButton from 'src/shared/components/question-button/QuestionButton';
import defaultStyles from './SpeciesStats.scss';
type PrimaryDataProps = {
primaryValue: string | number;
primaryUnit?: string;
helpText?: string;
};
type PropsWithSecondaryData = {
......@@ -84,6 +87,11 @@ const SpeciesStats = (props: SpeciesStatsProps) => {
{props.preLabel && (
<span className={styles.preLabel}>{props.preLabel}</span>
)}
{props.helpText && (
<span className={defaultStyles.questionButton}>
<QuestionButton helpText={props.helpText} />
</span>
)}
<div className={styles.label}>{props.label}</div>
......
......@@ -90,6 +90,17 @@ export const sampleData: RawSpeciesStats = {
total_introns: 25165,
average_intron_length: 4336.85
},
homology_stats: {
coverage: 98.8
},
variation_stats: {
short_variants: 713730678,
structural_variants: 32132047,
short_variants_with_phenotype_assertions: 13336864,
short_variants_with_publications: 303288,
short_variants_frequency_studies: 8,
structural_variants_with_phenotype_assertions: 1921150
},
regulation_stats: {
enhancers: 132592,
promoters: 35191
......@@ -158,6 +169,17 @@ export const sampleData: RawSpeciesStats = {
total_introns: 22805,
average_intron_length: 3049.46
},
homology_stats: {
coverage: 0
},
variation_stats: {
short_variants: 677181182,
structural_variants: 36348512,
short_variants_with_phenotype_assertions: 10233814,
short_variants_with_publications: 328161,
short_variants_frequency_studies: 8,
structural_variants_with_phenotype_assertions: 1682589
},
regulation_stats: {
enhancers: 92264,
promoters: 21822
......@@ -225,6 +247,9 @@ export const sampleData: RawSpeciesStats = {
average_exons_per_transcript: 1.17,
total_introns: 19,
average_intron_length: 1150.95
},
homology_stats: {
coverage: 93.1
}
},
caenorhabditis_elegans_GCA_000002985_3: {
......@@ -289,6 +314,9 @@ export const sampleData: RawSpeciesStats = {
average_exons_per_transcript: 3.93,
total_introns: 5737,
average_intron_length: 203.57
},
homology_stats: {
coverage: 51.8
}
},
plasmodium_falciparum_GCA_000002765_2: {
......@@ -353,6 +381,9 @@ export const sampleData: RawSpeciesStats = {
average_exons_per_transcript: 3.01,
total_introns: 308,
average_intron_length: 48.51
},
homology_stats: {
coverage: 43.3
}
},
saccharomyces_cerevisiae_GCA_000146045_2: {
......@@ -417,6 +448,17 @@ export const sampleData: RawSpeciesStats = {
average_exons_per_transcript: 1,
total_introns: 0,
average_intron_length: null
},
variation_stats: {
short_variants: 263537,
structural_variants: null,
short_variants_with_phenotype_assertions: null,
short_variants_with_publications: null,
short_variants_frequency_studies: null,
structural_variants_with_phenotype_assertions: null
},
homology_stats: {
coverage: 57.7
}
},
triticum_aestivum_GCA_900519105_1: {
......@@ -481,6 +523,17 @@ export const sampleData: RawSpeciesStats = {
average_exons_per_transcript: null,
total_introns: null,
average_intron_length: null
},
variation_stats: {
short_variants: 18093911,
structural_variants: null,
short_variants_with_phenotype_assertions: null,
short_variants_with_publications: null,
short_variants_frequency_studies: 1,
structural_variants_with_phenotype_assertions: null
},
homology_stats: {
coverage: 98.7
}
},
actinobacillus: {
......
......@@ -29,6 +29,8 @@ export enum SpeciesStatsSection {
NON_CODING_STATS = 'non_coding_stats',
PSEUDOGENES = 'pseudogene_stats',
ASSEMBLY = 'assembly_stats',
HOMOLOGY = 'homology_stats',
VARIATION = 'variation_stats',
REGULATION = 'regulation_stats'
}
......@@ -43,6 +45,9 @@ enum Groups {
ASSEMBLY = 'assembly',
ASSEMBLY_ANALYSIS = 'assembly_analysis',
TRANSCRIPTS = 'transcripts',
HOMOLOGY = 'homology',
VARIATION = 'variation',
VARIATION_EVIDENCE = 'variation_evidence',
REGULATION = 'regulation'
}
......@@ -56,6 +61,9 @@ const groupTitles = {
[Groups.ASSEMBLY]: 'Assembly',
[Groups.ASSEMBLY_ANALYSIS]: 'Analysis',
[Groups.TRANSCRIPTS]: 'Transcripts',
[Groups.HOMOLOGY]: 'Homology',
[Groups.VARIATION]: 'Variation',
[Groups.VARIATION_EVIDENCE]: 'Evidence',
[Groups.REGULATION]: 'Regulation'
};
......@@ -123,18 +131,37 @@ enum Stats {
PSEUDOGENES_TOTAL_INTRONS = 'total_introns',
PSEUDOGENES_AVERAGE_INTRON_LENGTH = 'average_intron_length',
// Homology stats
HOMOLOGY = 'homology',
HOMOLOGY_COVERAGE = 'coverage',
// Variation stats
VARIATION = 'variation',
SHORT_VARIANTS = 'short_variants',
STRUCTURAL_VARIANTS = 'structural_variants',
SHORT_VARIANTS_WITH_PHENOTYPE_ASSERTIONS = 'short_variants_with_phenotype_assertions',
SHORT_VARIANTS_WITH_PUBLICATIONS = 'short_variants_with_publications',
SHORT_VARIANTS_FREQUENCY_STUDIES = 'short_variants_frequency_studies',
STRUCTURAL_VARIANTS_WITH_PHENOTYPE_ASSERTIONS = 'structural_variants_with_phenotype_assertions',
// Regulation stats
REGULATION = 'regulation',
REGULATION_ENHANCERS = 'enhancers',
REGULATION_PROMOTERS = 'promoters'
}
const helpText = {
HOMOLOGY_COVERAGE:
'Coding genes with orthologues and/or paralogues with other species in Ensembl'
};
type SpeciesStatsSectionGroups = {
[key in SpeciesStatsSection]: {
title: Stats | string;
groups: Groups[];
summaryStatsKeys?: [Stats?, Stats?];
exampleLinkText?: string;
helpText?: string;
};
};
......@@ -162,6 +189,17 @@ export const sectionGroupsMap: SpeciesStatsSectionGroups = {
groups: [Groups.NON_CODING_GENES, Groups.NON_CODING_ANALYSIS],
summaryStatsKeys: [Stats.NON_CODING_GENES]
},
[SpeciesStatsSection.HOMOLOGY]: {
title: 'Homology',
groups: [Groups.HOMOLOGY],
summaryStatsKeys: [Stats.HOMOLOGY_COVERAGE],
helpText: helpText.HOMOLOGY_COVERAGE
},
[SpeciesStatsSection.VARIATION]: {
title: 'Variation',
groups: [Groups.VARIATION, Groups.VARIATION_EVIDENCE],
summaryStatsKeys: [Stats.SHORT_VARIANTS, Stats.STRUCTURAL_VARIANTS]
},
[SpeciesStatsSection.REGULATION]: {
title: 'Regulation',
groups: [Groups.REGULATION],
......@@ -262,6 +300,16 @@ const groupsStatsMap = {
[Stats.COMPONENT_SEQUENCES, Stats.CONTIG_N50]
],
[Groups.ASSEMBLY_ANALYSIS]: [[Stats.AVERAGE_GC_CONTENT]],
[Groups.HOMOLOGY]: [[Stats.HOMOLOGY_COVERAGE]],
[Groups.VARIATION]: [[Stats.SHORT_VARIANTS, Stats.STRUCTURAL_VARIANTS]],
[Groups.VARIATION_EVIDENCE]: [
[
Stats.SHORT_VARIANTS_WITH_PHENOTYPE_ASSERTIONS,
Stats.SHORT_VARIANTS_WITH_PUBLICATIONS,
Stats.SHORT_VARIANTS_FREQUENCY_STUDIES
],
[Stats.STRUCTURAL_VARIANTS_WITH_PHENOTYPE_ASSERTIONS]
],
[Groups.REGULATION]: [
[Stats.REGULATION_ENHANCERS, Stats.REGULATION_PROMOTERS]
]
......@@ -269,11 +317,13 @@ const groupsStatsMap = {
// Individual stat formatting options.
type StatsFormattingOption = {
preLabel?: string;
label: string;
headerUnit?: string;
primaryUnit?: string;
secondaryUnit?: string;
primaryValuePostfix?: string;
helpText?: string;
};
type StatsFormattingOptions = {
......@@ -458,6 +508,45 @@ const statsFormattingOptions: StatsFormattingOptions = {
label: 'Average GC content'
}
},
[SpeciesStatsSection.HOMOLOGY]: {
[Stats.HOMOLOGY]: {
label: 'Homology'
},
[Stats.HOMOLOGY_COVERAGE]: {
label: 'Coverage',
headerUnit: 'coverage',
primaryValuePostfix: '%'
}
},
[SpeciesStatsSection.VARIATION]: {
[Stats.VARIATION]: {
label: 'Variation'
},
[Stats.SHORT_VARIANTS]: {
label: 'Short variants',
headerUnit: 'short variants'
},
[Stats.STRUCTURAL_VARIANTS]: {
label: 'Structural variants',
headerUnit: 'structural variants'
},
[Stats.SHORT_VARIANTS_WITH_PHENOTYPE_ASSERTIONS]: {
preLabel: 'Short variants',
label: 'With phenotype assertions'
},
[Stats.SHORT_VARIANTS_WITH_PUBLICATIONS]: {
preLabel: 'Short variants',
label: 'With publications'
},
[Stats.SHORT_VARIANTS_FREQUENCY_STUDIES]: {
preLabel: 'Short variants',
label: 'Frequency studies'
},
[Stats.STRUCTURAL_VARIANTS_WITH_PHENOTYPE_ASSERTIONS]: {
preLabel: 'Structural variants',
label: 'With phenotype assertions'
}
},
[SpeciesStatsSection.REGULATION]: {
[Stats.REGULATION]: {
label: 'Regulation'
......@@ -505,7 +594,9 @@ const buildIndividualStat = (
const {
primaryValuePostfix = '',
label,
primaryUnit
primaryUnit,
preLabel,
helpText
} = statsFormattingOptions[section][primaryKey] as StatsFormattingOption;
if (typeof primaryValue === 'number') {
......@@ -513,9 +604,11 @@ const buildIndividualStat = (
}
return {
preLabel,
label: label || primaryKey,
primaryValue,
primaryUnit: primaryUnit
primaryUnit,
helpText
};
};
......@@ -620,7 +713,11 @@ export const getStatsForSection = (props: {
const data = sampleData[genome_id][section];
if (!data) return;
if (!data) {
return {
section
} as StatsSection;
}
const filteredData: {
[key: string]: string | number;
......@@ -640,9 +737,13 @@ export const getStatsForSection = (props: {
return;
}
const summaryStats = summaryStatsKeys
const availableSummaryStatsKeys = summaryStatsKeys?.filter(
(key) => key && (filteredData[key] || filteredData[key] === 0)
);
const summaryStats = availableSummaryStatsKeys
?.map((key) => {
return key
return key && (filteredData[key] || filteredData[key] === 0)
? buildHeaderStat({
primaryKey: key,
primaryValue: filteredData[key],
......@@ -661,7 +762,7 @@ export const getStatsForSection = (props: {
: undefined;
const isExpandedContentSame =
Object.keys(filteredData).length === summaryStatsKeys?.length;
Object.keys(filteredData).length === availableSummaryStatsKeys?.length;
if (isExpandedContentSame) {
return {
......@@ -677,7 +778,6 @@ export const getStatsForSection = (props: {
const processedStats = groupStats
.map((subGroupStats) => {
const processedSubGroupStats: IndividualStat[] = [];
subGroupStats.forEach((stat) => {
if (filteredData[stat] || filteredData[stat] === 0) {
const individualStat = buildIndividualStat({
......
@import 'src/styles/common';
.quesionButton {
.questionButton {
position: relative;
display: inline-block;
padding: 2px;
......
......@@ -51,7 +51,7 @@ const QuestionButton = (props: Props) => {
};
const className = classNames(
defaultStyles.quesionButton,
defaultStyles.questionButton,
{
[defaultStyles[props.styleOption as string]]: props.styleOption
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment