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

Cohort to Program naming #196

Merged
merged 1 commit into from
Nov 25, 2024
Merged
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
10 changes: 5 additions & 5 deletions src/store/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const primarySiteCount = {
'Tonsil C09': 50
};

export const cohortByNode = {
export const programByNode = {
BCGSC: {
POG: 50
},
Expand Down Expand Up @@ -84,7 +84,7 @@ export const fullClinicalData = {

export const PRIMARY_SITES = ['Breast', 'Trachea', 'Panceas'];

export const COHORTS = ['POG', 'Inspire', 'Biocan', 'Biodiva', 'Compass', 'Palms', 'IO-Alines'];
export const PROGRAMS = ['POG', 'Inspire', 'Biocan', 'Biodiva', 'Compass', 'Palms', 'IO-Alines'];

export const CLIN_METADATA = [
'patients',
Expand Down Expand Up @@ -135,8 +135,8 @@ export const DataVisualizationChartInfo = {
xAxis: 'Primary Site',
yAxis: 'Number of Primary Sites'
},
patients_per_cohort: {
title: 'Distribution of Cohort by Node',
patients_per_program: {
title: 'Distribution of Program by Node',
xAxis: 'Site',
yAxis: 'Number of Patients'
},
Expand All @@ -152,7 +152,7 @@ export const DataVisualizationChartInfo = {
}
};
export const validCharts = ['bar', 'line', 'scatter', 'column'];
export const validStackedCharts = ['patients_per_cohort', 'full_clinical_data', 'full_genomic_data'];
export const validStackedCharts = ['patients_per_program', 'full_clinical_data', 'full_genomic_data'];

// Highcharts Map requires a specific set of codes for provinces
// and territories, as represented by hcProvCodes below.
Expand Down
18 changes: 9 additions & 9 deletions src/ui-component/ingest/ClinicalIngest.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const Root = styled('div')({
function ClinicalIngest({ setTab, fileUpload, clinicalData }) {
// setTab should be a function that sets the tab to the genomic ingest page

const [authorizedCohorts, setAuthorizedCohorts] = useState([]);
const [authorizedPrograms, setAuthorizedPrograms] = useState([]);

useEffect(() => {
function fetchPrograms() {
Expand All @@ -56,13 +56,13 @@ function ClinicalIngest({ setTab, fileUpload, clinicalData }) {
const fields = [];
Object.keys(programs).forEach((program) => {
const field = [
makeField('Cohort', program),
makeField('Program', program),
makeField('Clinical Patients', programs[program].toString()),
makeField('Read Access', 'Unknown')
];
fields.push(field);
});
setAuthorizedCohorts(fields);
setAuthorizedPrograms(fields);
});
})
.catch((error) => console.log(error));
Expand All @@ -75,26 +75,26 @@ function ClinicalIngest({ setTab, fileUpload, clinicalData }) {
<Grid container direction="column" spacing={4}>
<Grid item>
<Typography align="left" className={classes.titleText}>
<b>Your authorized cohorts</b>
<b>Your authorized programs</b>
</Typography>
{authorizedCohorts.length > 0 ? (
{authorizedPrograms.length > 0 ? (
<Grid direction="row" spacing={3} container>
{authorizedCohorts.map((fields, index) => (
{authorizedPrograms.map((fields, index) => (
<Grid item xs={5} key={index}>
<DataRow rowWidth="100%" itemSize="0.9em" fields={fields} />
</Grid>
))}
</Grid>
) : (
<Typography align="left" className={classes.bodyText}>
No cohorts found.
No Programs found.
</Typography>
)}
</Grid>
<Grid item sx={{ width: '100%' }}>
<div>
<Typography align="left" className={classes.titleText}>
<b>Choose a cohort for validation</b>
<b>Choose a program for validation</b>
</Typography>
<Grid container sx={{ marginTop: '0.5em', marginLeft: '1em' }} direction="row" alignItems="center" spacing={2}>
<Grid item>
Expand All @@ -121,7 +121,7 @@ function ClinicalIngest({ setTab, fileUpload, clinicalData }) {
rowWidth="100%"
itemSize="0.9em"
fields={[
makeField('Cohort', clinicalData.donors[0].program_id),
makeField('Program', clinicalData.donors[0].program_id),
makeField('Clinical Patients', clinicalData.donors.length),
makeField('Read Access', '1')
]}
Expand Down
8 changes: 4 additions & 4 deletions src/ui-component/ingest/GenomicIngest.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ const Root = styled('div')({
function GenomicIngest({ beginIngest, fileUpload, clinicalData, genomicData }) {
const [ingestButtonEnabled, setIngestButtonEnabled] = useState(false);

const cohort = [
makeField('Cohort', clinicalData.donors[0].program_id),
const program = [
makeField('Program', clinicalData.donors[0].program_id),
makeField('Clinical Patients', clinicalData.donors.length),
makeField('Read Access', '1')
];
Expand All @@ -54,9 +54,9 @@ function GenomicIngest({ beginIngest, fileUpload, clinicalData, genomicData }) {
<Grid container direction="column" sx={{ flexGrow: 1 }} spacing={4}>
<Grid item>
<Typography align="left" className={classes.titleText}>
<b>Cohort for ingestion</b>
<b>Program for ingestion</b>
</Typography>
<DataRow rowWidth="100%" itemSize="0.9em" fields={cohort} />
<DataRow rowWidth="100%" itemSize="0.9em" fields={program} />
</Grid>
<Grid item width="100%">
<Typography align="left" className={classes.titleText}>
Expand Down
8 changes: 4 additions & 4 deletions src/views/clinicalGenomic/clinicalGenomicSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ const StyledMainCard = styled(MainCard)((_) => ({

const sections = [
{
id: 'cohorts summary',
id: 'Programs summary',
header: undefined,
component: <AuthorizationSections title="All Cohorts" />
component: <AuthorizationSections title="All Programs" />
},
{
id: 'counts',
Expand All @@ -110,9 +110,9 @@ const sections = [
component: <DataVisualization />
},
{
id: 'authorized cohorts',
id: 'authorized programs',
header: undefined,
component: <AuthorizationSections title="Authorized Cohorts" />
component: <AuthorizationSections title="Authorized Programs" />
},
{
id: 'clinical',
Expand Down
12 changes: 6 additions & 6 deletions src/views/clinicalGenomic/search/SearchHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function SearchHandler({ setLoading }) {
.then((data) => {
writer((old) => ({ ...old, sidebar: data }));
})
.then(() => fetchFederationStat('/patients_per_cohort'))
.then(() => fetchFederationStat('/patients_per_program'))
.then((data) => {
writer((old) => ({ ...old, federation: data }));
})
Expand Down Expand Up @@ -88,10 +88,10 @@ function SearchHandler({ setLoading }) {
age_at_diagnosis: CollateSummary(data, 'age_at_diagnosis'),
treatment_type_count: CollateSummary(data, 'treatment_type_count'),
primary_site_count: CollateSummary(data, 'primary_site_count'),
patients_per_cohort: {}
patients_per_program: {}
};
data.forEach((site) => {
discoveryCounts.patients_per_cohort[site.location.name] = site.results?.patients_per_cohort;
discoveryCounts.patients_per_program[site.location.name] = site.results?.patients_per_program;
});

writer((old) => ({ ...old, counts: discoveryCounts }));
Expand Down Expand Up @@ -124,7 +124,7 @@ function SearchHandler({ setLoading }) {
if (reader.filter?.node) {
data = data.filter((site) => !reader.filter.node.includes(site.location.name));
}
// Reorder the data, and fill out the patients per cohort
// Reorder the data, and fill out the patients per program
const clinicalData = {};
data.forEach((site) => {
if ('results' in site) {
Expand Down Expand Up @@ -162,12 +162,12 @@ function SearchHandler({ setLoading }) {

// Query 3: when the selected donor changes, re-query the server
useEffect(() => {
if (!reader.donorID || !reader.cohort) {
if (!reader.donorID || !reader.program) {
return;
}
setLoading(true);

const url = `v3/authorized/donor_with_clinical_data/program/${reader.cohort}/donor/${reader.donorID}`;
const url = `v3/authorized/donor_with_clinical_data/program/${reader.program}/donor/${reader.donorID}`;
trackPromise(
fetchFederation(url, 'katsu')
.then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions src/views/clinicalGenomic/widgets/dataVisualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function DataVisualization() {
};

const dataVis = {
patients_per_cohort: handleCensoring('patients_per_cohort', (site, _) => site, true) || {},
patients_per_program: handleCensoring('patients_per_program', (site, _) => site, true) || {},
diagnosis_age_count: handleCensoring('age_at_diagnosis', (_, age) => age.replace(/ Years$/, '')) || {},
treatment_type_count: handleCensoring('treatment_type_count') || {},
primary_site_count: handleCensoring('primary_site_count') || {}
Expand All @@ -93,7 +93,7 @@ function DataVisualization() {
const [dataValue, setDataValue] = useState(
localStorage.getItem('dataVisData') && JSON.parse(localStorage.getItem('dataVisData'))?.[0]
? JSON.parse(localStorage.getItem('dataVisData'))[0]
: 'patients_per_cohort'
: 'patients_per_program'
);
const [chartType, setChartType] = useState(
localStorage.getItem('dataVisChartType') && JSON.parse(localStorage.getItem('dataVisChartType'))?.[0]
Expand Down
2 changes: 1 addition & 1 deletion src/views/clinicalGenomic/widgets/genomicData.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function GenomicData() {
const columns = [
{ field: 'location', headerName: 'Node', minWidth: 120, sortable: false, filterable: false },
{ field: 'donor_id', headerName: 'Donor ID', minWidth: 150, sortable: false, filterable: false },
{ field: 'program_id', headerName: 'Cohort ID', minWidth: 150, sortable: false, filterable: false },
{ field: 'program_id', headerName: 'Program ID', minWidth: 150, sortable: false, filterable: false },
{ field: 'position', headerName: 'Position', minWidth: 150, sortable: false, filterable: false },
{ field: 'tumour_normal_designation', headerName: 'Tumour/Normal', minWidth: 200, sortable: false, filterable: false },
{ field: 'submitter_specimen_id', headerName: 'Sample Registration ID', minWidth: 300, sortable: false, filterable: false },
Expand Down
36 changes: 18 additions & 18 deletions src/views/clinicalGenomic/widgets/patientCountSingle.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,18 @@ function PatientCountSingle(props) {

const SumCensoredTotals = (countsArray) =>
countsArray.reduce(
(partialSum, cohortTotal) => {
if (typeof cohortTotal === 'object') {
if (cohortTotal.patients_count.startsWith('<')) {
return [partialSum[0], partialSum[1] + parseInt(cohortTotal.patients_count.substring(1), 10)];
(partialSum, programTotal) => {
if (typeof programTotal === 'object') {
if (programTotal.patients_count.startsWith('<')) {
return [partialSum[0], partialSum[1] + parseInt(programTotal.patients_count.substring(1), 10)];
}
const toAdd = parseInt(cohortTotal.patients_count, 10);
const toAdd = parseInt(programTotal.patients_count, 10);
return [partialSum[0] + toAdd, partialSum[1] + toAdd];
}
if (typeof cohortTotal === 'string' && cohortTotal.startsWith('<')) {
return [partialSum[0], partialSum[1] + parseInt(cohortTotal.substring(1), 10)];
if (typeof programTotal === 'string' && programTotal.startsWith('<')) {
return [partialSum[0], partialSum[1] + parseInt(programTotal.substring(1), 10)];
}
return [partialSum[0] + parseInt(cohortTotal, 10), partialSum[1] + parseInt(cohortTotal, 10)];
return [partialSum[0] + parseInt(programTotal, 10), partialSum[1] + parseInt(programTotal, 10)];
},
[0, 0]
);
Expand All @@ -86,7 +86,7 @@ function PatientCountSingle(props) {

const totalPatients = SumCensoredTotals(Object.values(counts.totals)) || [0, 0];
const patientsInSearch = SumCensoredTotals(Object.values(counts.counts)) || [0, 0];
const numCohorts = Object.values(counts.totals)?.length || 0;
const numPrograms = Object.values(counts.totals)?.length || 0;
return (
<StyledBox pr={2} sx={{ border: 1, borderRadius: 2, boxShadow: 2, borderColor: 'primary.main' }}>
<Grid container justifyContent="center" alignItems="center" spacing={2} className={classes.container}>
Expand All @@ -111,12 +111,12 @@ function PatientCountSingle(props) {
<Divider flexItem orientation="vertical" className={classes.divider} />
<Grid item xs={2}>
<Typography align="center" className={classes.patientEntry}>
{numCohorts}
{numPrograms}
</Typography>
</Grid>
<Divider flexItem orientation="vertical" className={classes.divider} />
<Grid item className={classes.button} pr={-2}>
{numCohorts > 1 ? (
{numPrograms > 1 ? (
<Button
onClick={(_) => setExpanded((old) => !old)}
variant="contained"
Expand All @@ -134,23 +134,23 @@ function PatientCountSingle(props) {
</Grid>

{expanded
? counts.totals.map((cohort) => {
const locked = !counts.unlockedPrograms?.some((programID) => programID === cohort.program_id);
? counts.totals.map((program) => {
const locked = !counts.unlockedPrograms?.some((programID) => programID === program.program_id);
return (
<Grid
container
justifyContent="center"
alignItems="center"
spacing={2}
key={cohort.program_id}
key={program.program_id}
className={classes.container}
>
<Grid item xs={2}>
<Typography variant="h5" align="center" className={classes.patientEntry}>
<b className={classes.patientEntry}>
{cohort.program_id}
{program.program_id}
{locked && (
<Tooltip title="Unauthorized Cohort" placement="right">
<Tooltip title="Unauthorized Program" placement="right">
<LockOutlinedIcon className={classes.lockIcon} />
</Tooltip>
)}
Expand All @@ -160,13 +160,13 @@ function PatientCountSingle(props) {
<Divider flexItem orientation="vertical" className={classes.divider} />
<Grid item xs={2}>
<Typography align="center" className={classes.patientEntry}>
{counts.counts?.[cohort.program_id] || 0}
{counts.counts?.[program.program_id] || 0}
</Typography>
</Grid>
<Divider flexItem orientation="vertical" className={classes.divider} />
<Grid item xs={2}>
<Typography align="center" className={classes.patientEntry}>
{cohort.patients_count || 0}
{program.patients_count || 0}
</Typography>
</Grid>
<Divider flexItem orientation="vertical" className={classes.divider} />
Expand Down
8 changes: 4 additions & 4 deletions src/views/clinicalGenomic/widgets/patientCounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ function PatientCounts() {
const context = useSearchResultsReaderContext();
const sites = context?.federation;
const programs = context?.programs;
const discoveryCounts = context?.counts?.patients_per_cohort;
const discoveryCounts = context?.counts?.patients_per_program;
const clinicalCounts = context?.clinical;

// Generate the map of site->cohort->numbers
// Generate the map of site->program->numbers
let siteData = [];
if (Array.isArray(sites)) {
siteData = sites.map((entry) => {
const counts = discoveryCounts?.[entry.location.name] || {};
const realCounts = clinicalCounts?.[entry.location.name]?.summary?.patients_per_cohort || {};
const realCounts = clinicalCounts?.[entry.location.name]?.summary?.patients_per_program || {};
let unlockedPrograms = [];
// Fill up the programs using the summary counts
if (Array.isArray(programs)) {
Expand Down Expand Up @@ -80,7 +80,7 @@ function PatientCounts() {
</Grid>
<Grid item xs={2}>
<Typography variant="h5" className={`${PREFIX}-header`}>
Total Cohorts
Total Programs
</Typography>
</Grid>
<Grid item xs={1} ml="auto" className={`${PREFIX}-button`}>
Expand Down
Loading
Loading