import { getPercentage } from '../../../shared/lib/FormatUtils';
import * as React from 'react';
import { SampleList, Sample, CancerStudy } from 'cbioportal-ts-api-client';
import _ from 'lodash';
import { buildCBioPortalPageUrl } from '../../../shared/api/urls';
export function getPatientSampleSummary(samples: any[], patients: any[]) {
if (samples.length !== patients.length) {
const patientUnits = patients.length === 1 ? 'patient' : 'patients';
const sampleUnits = samples.length === 1 ? 'sample' : 'samples';
return (
{patients.length} {patientUnits} /{' '}
{samples.length} {sampleUnits}
);
} else {
const units =
samples.length === 1 ? 'patient/sample' : 'patients/samples';
return (
{samples.length} {units}
);
}
}
export function getGeneSummary(hugoSymbols: string[]) {
switch (hugoSymbols.length) {
case 0:
return '';
case 1:
return hugoSymbols[0];
case 2:
return hugoSymbols.join(' & ');
default:
return `${hugoSymbols[0]}, ${hugoSymbols[1]} & ${
hugoSymbols.length === 3
? hugoSymbols[2]
: `${hugoSymbols.length - 2} other genes`
}`;
}
}
export function getAlterationSummary(
numSamples: number,
numPatients: number,
numAlteredSamples: number,
numAlteredPatients: number,
numGenes: number
) {
const prefix = `Queried gene${numGenes !== 1 ? 's are' : ' is'} altered in`;
const sampleSummaryPrefix = `${numAlteredSamples} (${getPercentage(
numAlteredSamples / numSamples
)}) of queried`;
if (numSamples !== numPatients) {
// note that by the pigeonhole principle, its not possible to have same number of samples and patients and
// for there to be more than one sample in a single patient. thus in the case that there are same # of samples
// and patients, it must be that numAlteredSamples === numAlteredPatients. Thus we're not hiding any info
// by only showing # altered patients if there are different # of samples and patients.
return (
{prefix}
•
{`${numAlteredPatients} (${getPercentage(
numAlteredPatients / numPatients
)}) of queried patients`}