-
Notifications
You must be signed in to change notification settings - Fork 596
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
Fix for frequency in multi-study view #11331
base: master
Are you sure you want to change the base?
Changes from all commits
1354c03
0f350d2
ba9b193
368c13b
c4b100f
5a157c9
22078e5
a533e29
94fbda8
ff17d92
2eeb7b7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
import org.cbioportal.model.Gistic; | ||
import org.cbioportal.model.GisticToGene; | ||
import org.cbioportal.model.MolecularProfile; | ||
import org.cbioportal.model.MolecularProfileCaseIdentifier; | ||
import org.cbioportal.model.MutSig; | ||
import org.springframework.lang.NonNull; | ||
|
||
|
@@ -15,6 +16,7 @@ | |
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.ArrayList; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
|
||
|
@@ -148,7 +150,7 @@ public static <S extends AlterationCountBase> void setupAlterationGeneCountsMap( | |
S alterationCountByGene = totalResult.get(key); | ||
alterationCountByGene.setTotalCount(alterationCountByGene.getTotalCount() + datum.getTotalCount()); | ||
alterationCountByGene.setNumberOfAlteredCases(alterationCountByGene.getNumberOfAlteredCases() + datum.getNumberOfAlteredCases()); | ||
alterationCountByGene.setNumberOfProfiledCases(alterationCountByGene.getNumberOfProfiledCases() + datum.getNumberOfProfiledCases()); | ||
alterationCountByGene.setNumberOfProfiledCases(0); //Set number of cases to zero | ||
Set<String> matchingGenePanelIds = new HashSet<>(); | ||
if (!alterationCountByGene.getMatchingGenePanelIds().isEmpty()) { | ||
matchingGenePanelIds.addAll(alterationCountByGene.getMatchingGenePanelIds()); | ||
|
@@ -159,10 +161,24 @@ public static <S extends AlterationCountBase> void setupAlterationGeneCountsMap( | |
alterationCountByGene.setMatchingGenePanelIds(matchingGenePanelIds); | ||
totalResult.put(key, alterationCountByGene); | ||
} else { | ||
datum.setNumberOfProfiledCases(0); //Ensure number of cases is initialized to zero | ||
totalResult.put(key, datum); | ||
} | ||
}); | ||
} | ||
|
||
public static <S extends AlterationCountBase> void updateAlterationGeneCountsMap( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also some comments explaining this function would be great. We're implementing new coding guidelines so it'll help us to add JavaDocs in the future. Thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added some comments int he code for clarity. |
||
Map<String, S> totalResult, // the map of all genes with at least one mutation in the whole cohort | ||
List<MolecularProfileCaseIdentifier> studyMolecularProfileCaseIdentifiers) { // the list of all cases in the study | ||
|
||
List<S> allGene= new ArrayList<>(totalResult.values()); // get all genes with at least one mutation in the whole cohort | ||
allGene.forEach(datum -> { // for each gene in the whole cohort | ||
String key = datum.getUniqueEventKey(); // get the unique key of the gene | ||
S alterationCountByGene = totalResult.get(key); // get the gene from the map | ||
alterationCountByGene.setNumberOfProfiledCases(alterationCountByGene.getNumberOfProfiledCases() + studyMolecularProfileCaseIdentifiers.size()); // the update the number of profiled cases for each study | ||
totalResult.put(key, alterationCountByGene); // update the map | ||
}); | ||
} | ||
|
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this second part it looks mostly duplicated from above old code. Is this intended? Could you elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function's structure is mostly inspired from setupAlterationGeneCountsMap, although updateAlterationGeneCountsMap use similar arguments in a different way. In the update function, TotalResults is now used in the place of studyAlterationCountByGenes and updated with identifiers information (studyMolecularProfileCaseIdentifiers).
Additionally, I've deleted a part of the function that was duplicated and was re-updating the gene panel information.