Skip to content

Commit

Permalink
update pipeline labels
Browse files Browse the repository at this point in the history
  • Loading branch information
austenem committed Oct 23, 2024
1 parent 0050e9f commit 05f209c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function HelperPanelBody() {
{currentDataset.description}
</HelperPanelBodyItem>
)}
<HelperPanelBodyItem label="Pipeline">
<HelperPanelBodyItem label="Analysis Type">
{currentDataset.pipeline ?? currentDataset.assay_display_name[0]}
</HelperPanelBodyItem>
<HelperPanelBodyItem label="Group">{currentDataset.group_name}</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
@@ -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 @@ -95,7 +95,7 @@ it('checks if dataset is published', () => {
});

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');
const { analysesText, analysesCountText } = useAnalysesCountInfo(testDatasets.map((dataset) => dataset._source));
expect(analysesText).toBe('Pipelines (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,
};
}

0 comments on commit 05f209c

Please sign in to comment.