Skip to content

Commit

Permalink
Implement RFC85 Dynamic Virtual Study (#5016)
Browse files Browse the repository at this point in the history
* Implement RFC85 Dynamic Virtual Study


---------

Co-authored-by: pieterlukasse <[email protected]>
  • Loading branch information
forus and pieterlukasse authored Nov 21, 2024
1 parent 69f34fb commit 1f7e44e
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 75 deletions.
4 changes: 2 additions & 2 deletions src/appShell/App/usageAgreements/StudyAgreement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export const StudyAgreement: React.FunctionComponent<{}> = function({}) {
href="https://mskcc.sharepoint.com/sites/pub-ResearchDG/SitePages/Home.aspx?ga=1"
target="_blank"
>
MSK-IMPACT Memorial Hospital Research Data Governance publication
guidelines
MSK-IMPACT Memorial Hospital Research Data Governance
publication guidelines
</a>
.
</>,
Expand Down
8 changes: 8 additions & 0 deletions src/globalStyles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ div:active {
}
}

.form-group-inline {
@extend .form-group;

label {
margin-right: 6px;
}
}

.posRelative {
position: relative;
}
Expand Down
25 changes: 16 additions & 9 deletions src/pages/studyView/StudyViewUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,8 @@ export function getVirtualStudyDescription(
attributeNamesSet: { [id: string]: string },
molecularProfileNameSet: { [id: string]: string },
caseListNameSet: { [key: string]: string },
user?: string
user?: string,
hideSampleCounts: boolean = false
) {
let descriptionLines: string[] = [];
const createdOnStr = 'Created on';
Expand All @@ -917,18 +918,24 @@ export function getVirtualStudyDescription(
_.flatMap(studyWithSamples, study => study.uniqueSampleKeys)
);
descriptionLines.push(
`${uniqueSampleKeys.length} sample${
uniqueSampleKeys.length > 1 ? 's' : ''
} from ${studyWithSamples.length} ${
studyWithSamples.length > 1 ? 'studies:' : 'study:'
}`
(hideSampleCounts
? 'Samples'
: `${uniqueSampleKeys.length} sample${
uniqueSampleKeys.length > 1 ? 's' : ''
}`) +
` from ${studyWithSamples.length} ${
studyWithSamples.length > 1 ? 'studies:' : 'study:'
}`
);
//add individual studies sample count
studyWithSamples.forEach(studyObj => {
descriptionLines.push(
`- ${studyObj.name} (${
studyObj.uniqueSampleKeys.length
} sample${uniqueSampleKeys.length > 1 ? 's' : ''})`
`- ${studyObj.name}` +
(hideSampleCounts
? ''
: ` (${studyObj.uniqueSampleKeys.length} sample${
uniqueSampleKeys.length > 1 ? 's' : ''
})`)
);
});
//add filters
Expand Down
135 changes: 122 additions & 13 deletions src/pages/studyView/virtualStudy/VirtualStudy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export default class VirtualStudy extends React.Component<
{}
> {
@observable.ref private name: string;
@observable.ref private description: string;
@observable.ref private customDescription: string | undefined;
@observable.ref private dynamic: boolean = false;

@observable private saving = false;
@observable private sharing = false;
Expand All @@ -107,17 +108,6 @@ export default class VirtualStudy extends React.Component<
super(props);
makeObservable(this);
this.name = props.name || '';
this.description =
props.description ||
getVirtualStudyDescription(
this.props.description,
this.props.studyWithSamples,
this.props.filter,
this.attributeNamesSet,
this.props.molecularProfileNameSet,
this.props.caseListNameSet,
this.props.user
);
}

@computed get namePlaceHolder() {
Expand Down Expand Up @@ -167,6 +157,7 @@ export default class VirtualStudy extends React.Component<
study => study.studyId
),
studies: studies,
dynamic: this.dynamic,
};
return await sessionServiceClient.saveVirtualStudy(
parameters,
Expand Down Expand Up @@ -231,6 +222,30 @@ export default class VirtualStudy extends React.Component<
);
}

getDefuaultDescriptionByType(dynamic: boolean) {
return getVirtualStudyDescription(
this.props.description,
this.props.studyWithSamples,
this.props.filter,
this.attributeNamesSet,
this.props.molecularProfileNameSet,
this.props.caseListNameSet,
this.props.user,
dynamic
);
}

@computed get description() {
const noCustomDescriptionProvided =
this.customDescription == undefined ||
this.customDescription ===
this.getDefuaultDescriptionByType(!this.dynamic);
if (noCustomDescriptionProvided) {
return this.getDefuaultDescriptionByType(this.dynamic);
}
return this.customDescription || '';
}

render() {
return (
<div
Expand Down Expand Up @@ -292,12 +307,106 @@ export default class VirtualStudy extends React.Component<
placeholder="Virtual study description (Optional)"
value={this.description}
onChange={event =>
(this.description =
(this.customDescription =
event.currentTarget.value)
}
/>
</div>

<div className="form-group-inline">
<label>Type:</label>
<label>
<input
type="radio"
name="option"
value="static"
checked={!this.dynamic}
onChange={_ =>
(this.dynamic = false)
}
/>{' '}
Static
</label>
<label>
<input
type="radio"
name="option"
value="dynamic"
checked={this.dynamic}
onChange={_ =>
(this.dynamic = true)
}
/>{' '}
Dynamic
</label>
<DefaultTooltip
mouseEnterDelay={0}
placement="right"
overlay={
<div>
<p>
<strong>
Type of Virtual
Study:
</strong>
</p>
<p>
This Virtual Study
will contain the set
of sample IDs
currently selected.
Furthermore, you can
define this Virtual
Study to be either
static or dynamic:
</p>
<ul>
<li>
<strong>
Static
</strong>{' '}
– Sample IDs are
the ones
currently
selected and no
new samples are
added to this
Virtual Study
set, even if the
database gets
updated with new
samples that
match the same
filtering/selection
criteria as the
samples in the
current set.
</li>
<li>
<strong>
Dynamic
</strong>{' '}
– Unlike the
Static option,
any new samples
added to the
database that
match the
criteria of this
Virtual Study
will
automatically be
included in its
sample set.
</li>
</ul>
</div>
}
>
<FontAwesome name="question-circle" />
</DefaultTooltip>
</div>

<div>
{this.showSaveButton && (
<button
Expand Down
108 changes: 57 additions & 51 deletions src/pages/studyView/virtualStudy/VirtualStudyModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,60 @@ export interface IVirtualStudyModalProps {
onHide: () => void;
}

export const VirtualStudyModal: React.FunctionComponent<IVirtualStudyModalProps> = observer(({
appStore,
pageStore,
message,
onHide,
}) => {
const isLoading = [
pageStore.filteredVirtualStudies,
pageStore.studyWithSamples,
pageStore.filteredVirtualStudies,
pageStore.molecularProfileNameSet,
pageStore.molecularProfileNameSet,
].some(result => result.isPending);
return (
<Modal onHide={onHide} show={true}>
<Modal.Header closeButton>
<Modal.Title>Create a Virtual Study</Modal.Title>
</Modal.Header>
<Modal.Body>
{isLoading ?
<LoadingIndicator isLoading={true}/>
: <>
{message || null}
<VirtualStudy
user={appStore.userName}
name={
pageStore.isSingleVirtualStudyPageWithoutFilter
? pageStore.filteredVirtualStudies.result[0].data
.name
: undefined
}
description={
pageStore.isSingleVirtualStudyPageWithoutFilter
? pageStore.filteredVirtualStudies.result[0].data
.description
: undefined
}
studyWithSamples={pageStore.studyWithSamples.result}
selectedSamples={pageStore.selectedSamples.result}
filter={pageStore.userSelections}
attributesMetaSet={pageStore.chartMetaSet}
molecularProfileNameSet={
pageStore.molecularProfileNameSet.result || {}
}
caseListNameSet={pageStore.caseListNameSet.result || {}}
/>
</>}
</Modal.Body>
</Modal>
);
});
export const VirtualStudyModal: React.FunctionComponent<IVirtualStudyModalProps> = observer(
({ appStore, pageStore, message, onHide }) => {
const isLoading = [
pageStore.filteredVirtualStudies,
pageStore.studyWithSamples,
pageStore.filteredVirtualStudies,
pageStore.molecularProfileNameSet,
pageStore.molecularProfileNameSet,
].some(result => result.isPending);
return (
<Modal onHide={onHide} show={true}>
<Modal.Header closeButton>
<Modal.Title>Create a Virtual Study</Modal.Title>
</Modal.Header>
<Modal.Body>
{isLoading ? (
<LoadingIndicator isLoading={true} />
) : (
<>
{message || null}
<VirtualStudy
user={appStore.userName}
name={
pageStore.isSingleVirtualStudyPageWithoutFilter
? pageStore.filteredVirtualStudies
.result[0].data.name
: undefined
}
description={
pageStore.isSingleVirtualStudyPageWithoutFilter
? pageStore.filteredVirtualStudies
.result[0].data.description
: undefined
}
studyWithSamples={
pageStore.studyWithSamples.result
}
selectedSamples={
pageStore.selectedSamples.result
}
filter={pageStore.userSelections}
attributesMetaSet={pageStore.chartMetaSet}
molecularProfileNameSet={
pageStore.molecularProfileNameSet.result ||
{}
}
caseListNameSet={
pageStore.caseListNameSet.result || {}
}
/>
</>
)}
</Modal.Body>
</Modal>
);
}
);

0 comments on commit 1f7e44e

Please sign in to comment.