Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Austenem/CAT-959 Update epic labels #3580

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG-update-epic-labels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Use assay_display_name instead of pipeline when labelling EPIC dataset sections.
- Update language in processed dataset sections from "pipeline" to "analysis".
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ function HelperPanelBody() {
{currentDataset.description}
</HelperPanelBodyItem>
)}
<HelperPanelBodyItem label="Pipeline">{currentDataset.pipeline}</HelperPanelBodyItem>
<HelperPanelBodyItem label="Analysis Type">
{currentDataset.pipeline ?? currentDataset.assay_display_name[0]}
</HelperPanelBodyItem>
<HelperPanelBodyItem label="Group">{currentDataset.group_name}</HelperPanelBodyItem>
<HelperPanelBodyItem label={dateLabel}>{date && formatDate(date, 'yyyy-MM-dd')}</HelperPanelBodyItem>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { sectionIconMap } from 'js/shared-styles/icons/sectionIconMap';
import ProcessedDataset from './ProcessedDataset';
import { SectionDescription } from './ProcessedDataset/SectionDescription';
import HelperPanel from './HelperPanel';
import { usePipelineCountsInfo, useSortedSearchHits } from './hooks';
import { useAnalysesCountInfo, useSortedSearchHits } from './hooks';
import CollapsibleDetailPageSection from '../DetailPageSection/CollapsibleDetailPageSection';

function ProcessedDataSection() {
const processedDatasets = useProcessedDatasets();
const sortedSearchHits = useSortedSearchHits(processedDatasets.searchHits);

const { pipelinesText, pipelineCountsText } = usePipelineCountsInfo(
const { analysesText, analysesCountText } = useAnalysesCountInfo(
processedDatasets.searchHits.map((dataset) => dataset._source),
);

Expand All @@ -25,7 +25,7 @@ function ProcessedDataSection() {
icon={sectionIconMap['processed-data']}
>
<SectionDescription
addendum={<LabelledSectionText label={pipelinesText}>{pipelineCountsText}</LabelledSectionText>}
addendum={<LabelledSectionText label={analysesText}>{analysesCountText}</LabelledSectionText>}
>
This section lists analyses generated based on this dataset. These analyses are represented as processed
datasets and are either generated by HuBMAP using uniform processing pipelines or by an external processing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function ProcessedDatasetAccordion({ children }: PropsWithChildren) {
<AccordionSummary expandIcon={<ArrowDropDownRounded />}>
{isLoading ? iconPlaceholder : visualizationIcon}
<Typography variant="subtitle1" color="inherit" component="h4">
{sectionDataset.pipeline}
{sectionDataset.pipeline ?? sectionDataset.assay_display_name[0]}
</Typography>
<Typography variant="body1" ml="auto" component="div" display="flex" alignItems="center" gap={1}>
<StatusIcon status={sectionDataset.status} noColor={isExpanded} tooltip />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { CreationAction } from 'js/components/types';
import { renderHook } from 'test-utils/functions';
import { useSortedSearchHits, createdByCentralProcess, datasetIsPublished, usePipelineCountsInfo } from './hooks';
import { useSortedSearchHits, createdByCentralProcess, datasetIsPublished, useAnalysesCountInfo } from './hooks';

const testDatasets: {
_id: string;
_index: string;
_score: number;
_source: {
assay_display_name: string[];
assay_display_name: string;
created_timestamp: number;
creation_action: CreationAction;
entity_type: string;
Expand All @@ -24,7 +24,7 @@ const testDatasets: {
_index: 'hm_prod_consortium_portal',
_score: 1,
_source: {
assay_display_name: ['CODEX [Cytokit + SPRM]'],
assay_display_name: 'CODEX [Cytokit + SPRM]',
created_timestamp: 1688952984040,
creation_action: 'Central Process',
entity_type: 'Dataset',
Expand All @@ -41,7 +41,7 @@ const testDatasets: {
_index: 'hm_prod_consortium_portal',
_score: 1,
_source: {
assay_display_name: ['CODEX [Cytokit + SPRM]'],
assay_display_name: 'CODEX [Cytokit + SPRM]',
created_timestamp: 1689198074733,
creation_action: 'Central Process',
entity_type: 'Dataset',
Expand All @@ -58,7 +58,7 @@ const testDatasets: {
_index: 'hm_prod_consortium_portal',
_score: 1,
_source: {
assay_display_name: ['External (Segmentation Mask)'],
assay_display_name: 'External (Segmentation Mask)',
created_timestamp: 1689198074733,
creation_action: 'External Process',
entity_type: 'Dataset',
Expand Down Expand Up @@ -94,8 +94,8 @@ it('checks if dataset is published', () => {
expect(datasetIsPublished(testDatasets[2]._source)).toBe(true);
});

it('counts pipelines and their occurrences', () => {
const { pipelinesText, pipelineCountsText } = usePipelineCountsInfo(testDatasets.map((dataset) => dataset._source));
expect(pipelinesText).toBe('Pipelines (2)');
expect(pipelineCountsText).toBe('Cytokit + SPRM (2) and Segmentation Mask');
it('counts analyses and their occurrences', () => {
const { analysesText, analysesCountText } = useAnalysesCountInfo(testDatasets.map((dataset) => dataset._source));
expect(analysesText).toBe('Analyses (2)');
expect(analysesCountText).toBe('Cytokit + SPRM (2) and Segmentation Mask');
});
26 changes: 13 additions & 13 deletions context/app/static/js/components/detailPage/ProcessedData/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,26 @@ export function useSortedSearchHits(datasets: ReturnType<typeof useProcessedData
}

/**
* Formats the processed datasets' pipelines and their counts for presentation.
* @param datasets The processed datasets to count the pipelines of.
* @returns Text for the pipelines label, and additional text for each pipeline and its count.
* Formats the processed datasets' analyses and their counts for presentation.
* @param datasets The processed datasets to count the analyses of.
* @returns Text for the analyses label, and additional text for each analysis and its count.
*/
export function usePipelineCountsInfo(datasets: Pick<ProcessedDatasetInfo, 'pipeline'>[]) {
const pipelines = datasets.map((dataset) => dataset.pipeline);
const pipelineCounts = pipelines.reduce(
(acc, pipeline) => {
acc[pipeline] = (acc[pipeline] || 0) + 1;
export function useAnalysesCountInfo(datasets: Pick<ProcessedDatasetInfo, 'pipeline' | 'assay_display_name'>[]) {
const analyses = datasets.map((dataset) => dataset.pipeline ?? dataset.assay_display_name[0]);
const analysesCount = analyses.reduce(
(acc, analysis) => {
acc[analysis] = (acc[analysis] || 0) + 1;
return acc;
},
{} as Record<string, number>,
);
const pipelinesText = `Pipelines (${Object.keys(pipelineCounts).length})`;
const pipelineCountsText = generateCommaList(
Object.entries(pipelineCounts).map(([pipeline, count]) => (count > 1 ? `${pipeline} (${count})` : pipeline)),
const analysesText = `Analyses (${Object.keys(analysesCount).length})`;
const analysesCountText = generateCommaList(
Object.entries(analysesCount).map(([analysis, count]) => (count > 1 ? `${analysis} (${count})` : analysis)),
);

return {
pipelinesText,
pipelineCountsText,
analysesText,
analysesCountText,
};
}
6 changes: 4 additions & 2 deletions context/app/static/js/pages/Dataset/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ function getProcessedDatasetSection({
hit: Required<SearchHit<ProcessedDatasetInfo>>;
conf?: VitessceConf;
}) {
const { pipeline, hubmap_id, files, metadata, visualization, creation_action, contributors } = hit._source;
const { pipeline, assay_display_name, hubmap_id, files, metadata, visualization, creation_action, contributors } =
hit._source;

const shouldDisplaySection = {
summary: true,
Expand All @@ -146,10 +147,11 @@ function getProcessedDatasetSection({
};

const sectionsToDisplay = Object.entries(shouldDisplaySection).filter(([_k, v]) => v === true);
const sectionTitle = pipeline ?? assay_display_name[0] ?? hubmap_id;

return {
// TODO: Improve the lookup for descendants to exclude anything with a missing pipeline name
...getSectionFromString(pipeline ?? hubmap_id, datasetSectionId(hit._source, 'section')),
...getSectionFromString(sectionTitle, datasetSectionId(hit._source, 'section')),
items: sectionsToDisplay.map(([s]) => ({
...getSectionFromString(s, datasetSectionId(hit._source, s)),
hash: datasetSectionId(hit._source, s),
Expand Down
Loading