Skip to content

Commit

Permalink
cancertype experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
MaDoeb committed Oct 10, 2024
1 parent bd1c7f5 commit 8230ced
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3574,13 +3574,24 @@ export class PatientViewPageStore {
clinicalDataDict,
'PATIENT_DISPLAY_NAME'
),
cancertype: getOrDefault(clinicalDataDict, 'TEST'),
cancertype: tumorTypeResolver(
getSampleTumorTypeMap(
this.clinicalDataForSamples.result,
this.studyMetaData.result?.cancerType.name
)
),
mutationData: mutationData,
});
}

console.group('### TEST INITIAL PATIENTS ###');
console.log(result);
console.log(
getSampleTumorTypeMap(
this.clinicalDataForSamples.result,
this.studyMetaData.result?.cancerType.name
)
);
console.groupEnd();

return result;
Expand Down
19 changes: 14 additions & 5 deletions src/pages/patientView/patientSimilarity/patientSimilarityTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import LoadingIndicator from 'shared/components/loadingIndicator/LoadingIndicato
import { DefaultTooltip } from 'cbioportal-frontend-commons';
import { Button } from 'react-bootstrap';
import { IClinicalTrial } from 'cbioportal-utils';
import {
SimilarPatient,
fetchPatientsPage,
} from 'shared/api/SimilarPatientsAPI';
import { SimilarPatient } from 'shared/api/SimilarPatientsAPI';
import { getServerConfig } from 'config/config';
import { MutationSelect } from './MutationSelect';

Expand All @@ -28,6 +25,7 @@ import {
import { ITherapyRecommendation, IGeneticAlteration } from 'cbioportal-utils';
import SampleManager from 'pages/patientView/SampleManager';
import { forIn } from 'lodash';
import { getPatientViewUrl, getSampleViewUrl } from 'shared/api/urls';

enum ColumnKey {
//patient_id: string;
Expand Down Expand Up @@ -73,7 +71,17 @@ export class PatientSimilarityTable extends React.Component<
},
{
name: ColumnKey.NAME,
render: (patient: SimilarPatient) => <div>{patient.name}</div>,
render: (patient: SimilarPatient) => (
<a
href={getPatientViewUrl(
patient.study_id,
patient.patient_id
)}
target="_blank"
>
{patient.name}
</a>
),
width: 250,
resizable: true,
},
Expand Down Expand Up @@ -215,6 +223,7 @@ export class PatientSimilarityTable extends React.Component<
onClick={() => {
this.startSearch();
}}
className={'btn btn-default'}
>
Search
</button>
Expand Down
172 changes: 86 additions & 86 deletions src/shared/api/SimilarPatientsAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,95 +84,95 @@ export interface SimilarPatient {
age: number;
gender: string;
name: string;
cancertype: string;
cancertype: string | undefined;
mutationData: Mutation[];
}

export async function fetchPatientsPage(
page: number = 0,
pageSize: number = 10,
client: CBioPortalAPI = defaultClient
) {
//'keyword'?: string;
//'projection'?: "ID" | "SUMMARY" | "DETAILED" | "META";
//'pageSize'?: number;
//'pageNumber'?: number;
//'direction'?: "ASC" | "DESC";
//$queryParameters?: any;
var patients: SimilarPatient[] = [];

const rawPatients = await client.getAllPatientsUsingGET({
projection: 'SUMMARY',
pageSize: pageSize,
pageNumber: page,
});

//console.log(rawPatients)

// GET ALL MOLECULAR PROFILE IDS

//const currentMolecularProfiles = client.getAllMolecularProfilesInStudyUsingGET({
// studyId: clinicalDataDict.studyId,
//});
const molecularProfiles: MolecularProfile[] = await client.getAllMolecularProfilesUsingGET(
{
projection: 'SUMMARY',
}
);

rawPatients.forEach(async patient => {
(async function(patient) {
// GET CLINICAL DATA
const currentClinicalData = await client.getAllClinicalDataOfPatientInStudyUsingGET(
{
studyId: patient.studyId,
patientId: patient.patientId,
}
);
const clinicalDataDict = clinicalData2Dict(currentClinicalData);

//console.group('### TEST ###');
//console.log(clinicalDataDict)
//console.groupEnd();

// GET SAMPLE IDS / molecular profile ids

const mutationalProfile = findMolecularProfile(
molecularProfiles,
patient.studyId,
AlterationTypeConstants.MUTATION_EXTENDED
);

const samples = await fetchSamplesForPatient(
patient.studyId,
patient.patientId
);
const currentSamples = samples.map(el => el.sampleId);

// GET MUTATIONS
const mutationFilter = {
sampleIds: currentSamples,
} as MutationFilter;
const mutationData = await fetchMutationData(
mutationFilter,
mutationalProfile?.molecularProfileId
);

// COLLECT DATA
patients.push({
patient_id: patient.patientId,
study_id: patient.studyId,
age: getOrDefault(clinicalDataDict, 'AGE', undefined, Number),
gender: getOrDefault(clinicalDataDict, 'GENDER'),
name: getOrDefault(clinicalDataDict, 'PATIENT_DISPLAY_NAME'),
cancertype: getOrDefault(clinicalDataDict, 'TEST'),
mutationData: [],
});
})(patient);
});

return patients;
}
//export async function fetchPatientsPage(
// page: number = 0,
// pageSize: number = 10,
// client: CBioPortalAPI = defaultClient
//) {
// //'keyword'?: string;
// //'projection'?: "ID" | "SUMMARY" | "DETAILED" | "META";
// //'pageSize'?: number;
// //'pageNumber'?: number;
// //'direction'?: "ASC" | "DESC";
// //$queryParameters?: any;
// var patients: SimilarPatient[] = [];
//
// const rawPatients = await client.getAllPatientsUsingGET({
// projection: 'SUMMARY',
// pageSize: pageSize,
// pageNumber: page,
// });
//
// //console.log(rawPatients)
//
// // GET ALL MOLECULAR PROFILE IDS
//
// //const currentMolecularProfiles = client.getAllMolecularProfilesInStudyUsingGET({
// // studyId: clinicalDataDict.studyId,
// //});
// const molecularProfiles: MolecularProfile[] = await client.getAllMolecularProfilesUsingGET(
// {
// projection: 'SUMMARY',
// }
// );
//
// rawPatients.forEach(async patient => {
// (async function(patient) {
// // GET CLINICAL DATA
// const currentClinicalData = await client.getAllClinicalDataOfPatientInStudyUsingGET(
// {
// studyId: patient.studyId,
// patientId: patient.patientId,
// }
// );
// const clinicalDataDict = clinicalData2Dict(currentClinicalData);
//
// //console.group('### TEST ###');
// //console.log(clinicalDataDict)
// //console.groupEnd();
//
// // GET SAMPLE IDS / molecular profile ids
//
// const mutationalProfile = findMolecularProfile(
// molecularProfiles,
// patient.studyId,
// AlterationTypeConstants.MUTATION_EXTENDED
// );
//
// const samples = await fetchSamplesForPatient(
// patient.studyId,
// patient.patientId
// );
// const currentSamples = samples.map(el => el.sampleId);
//
// // GET MUTATIONS
// const mutationFilter = {
// sampleIds: currentSamples,
// } as MutationFilter;
// const mutationData = await fetchMutationData(
// mutationFilter,
// mutationalProfile?.molecularProfileId
// );
//
// // COLLECT DATA
// patients.push({
// patient_id: patient.patientId,
// study_id: patient.studyId,
// age: getOrDefault(clinicalDataDict, 'AGE', undefined, Number),
// gender: getOrDefault(clinicalDataDict, 'GENDER'),
// name: getOrDefault(clinicalDataDict, 'PATIENT_DISPLAY_NAME'),
// cancertype: getOrDefault(clinicalDataDict, 'TEST'),
// mutationData: [],
// });
// })(patient);
// });
//
// return patients;
//}

function findMolecularProfile(
molecularProfiles: MolecularProfile[],
Expand Down

0 comments on commit 8230ced

Please sign in to comment.