Skip to content

Commit

Permalink
Update gene constraints to use gnomad v4.0 data
Browse files Browse the repository at this point in the history
Correct spelling of GeneConstraints.geneContraint() to geneConstraint()
  • Loading branch information
julesjacobsen committed Feb 7, 2024
1 parent 69402bf commit 55a73b7
Show file tree
Hide file tree
Showing 9 changed files with 101,000 additions and 19,814 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,47 +41,7 @@
/**
* @since 13.1.0
*/
public class GeneConstraint {

private final String geneSymbol;
private final String transcriptId;
private final double pLI;
private final double loeuf;
private final double loeufLower;
private final double loeufUpper;

public GeneConstraint(String geneSymbol, String transcriptId, double pLI, double loeuf, double loeufLower, double loeufUpper) {
this.geneSymbol = geneSymbol;
this.transcriptId = transcriptId;
this.pLI = pLI;
this.loeuf = loeuf;
this.loeufLower = loeufLower;
this.loeufUpper = loeufUpper;
}

public String geneSymbol() {
return geneSymbol;
}

public String transcriptId() {
return transcriptId;
}

public double pLI() {
return pLI;
}

public double loeuf() {
return loeuf;
}

public double loeufLower() {
return loeufLower;
}

public double loeufUpper() {
return loeufUpper;
}
public record GeneConstraint(String geneSymbol, String transcriptId, double pLI, double loeuf, double loeufLower, double loeufUpper, double missenseZ, double synonymousZ) {

/**
* For the interpretation of Mendelian diseases cases, we suggest using the upper bound of the oe CI < 0.35 as a threshold if needed.
Expand All @@ -92,31 +52,7 @@ public boolean isLossOfFunctionIntolerant() {
//gnomAD suggest using a loeufUpper < 0.35;
// However varsome suggests a relaxed metric has better recall due to lower FP.
// https://varsome.com/about/resources/acmg-implementation/#pvs1
return loeuf < 0.7635;
return loeuf < 0.7555;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GeneConstraint that = (GeneConstraint) o;
return Double.compare(that.pLI, pLI) == 0 && Double.compare(that.loeuf, loeuf) == 0 && Double.compare(that.loeufLower, loeufLower) == 0 && Double.compare(that.loeufUpper, loeufUpper) == 0 && geneSymbol.equals(that.geneSymbol) && transcriptId.equals(that.transcriptId);
}

@Override
public int hashCode() {
return Objects.hash(geneSymbol, transcriptId, pLI, loeuf, loeufLower, loeufUpper);
}

@Override
public String toString() {
return "GeneContraint{" +
"geneSymbol='" + geneSymbol + '\'' +
", transcriptId='" + transcriptId + '\'' +
", pLI=" + pLI +
", loeuf=" + loeuf +
", loeufLower=" + loeufLower +
", loeufUpper=" + loeufUpper +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,25 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
import java.util.*;

/**
* @since 13.1.0
*/
public class GeneConstraints {

private static final Map<String, GeneConstraint> geneConstraints = GnomadGeneConstraintParser.readGeneConstraints("gnomad.v2.1.1.gene-constraints.tsv");
private static final Map<String, GeneConstraint> GENE_CONSTRAINTS = GnomadGeneConstraintParser.readGeneConstraints("gnomad.v4.0.gene-constraints.tsv");

private GeneConstraints() {
}

@Nullable
public static GeneConstraint geneContraint(String geneSymbol) {
return geneConstraints.get(geneSymbol);
public static GeneConstraint geneConstraint(String geneSymbol) {
return GENE_CONSTRAINTS.get(geneSymbol);
}

public static Collection<GeneConstraint> geneConstraints() {
return GENE_CONSTRAINTS.values();
}

private static class GnomadGeneConstraintParser {
Expand All @@ -53,9 +54,9 @@ private static Map<String, GeneConstraint> readGeneConstraints(String constraint
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(getResourceAsStream(constraintsFile)))) {
for (String line; (line = bufferedReader.readLine()) != null; ) {
if (!line.startsWith("#")) {
GeneConstraint geneContraint = parseGeneConstraint(line);
if (!Double.isNaN(geneContraint.loeufUpper())) {
geneConstraints.put(geneContraint.geneSymbol(), geneContraint);
GeneConstraint geneConstraint = parseGeneConstraint(line);
if (geneConstraint != null) {
geneConstraints.put(geneConstraint.geneSymbol(), geneConstraint);
}
}
}
Expand All @@ -66,14 +67,21 @@ private static Map<String, GeneConstraint> readGeneConstraints(String constraint
}

private static GeneConstraint parseGeneConstraint(String line) {
// gene transcript mane_select lof.oe lof.pLI lof.oe_ci.lower lof.oe_ci.upper mis.z_score syn.z_score
String[] fields = line.split("\t");
String geneSymbol = fields[0];
String transcriptId = fields[1];
double pLI = parseDouble(fields[2]);
boolean isManeSelect = Boolean.parseBoolean(fields[2]);
if (geneSymbol.equals("NA") || !isManeSelect) {
return null;
}
double pLI = parseDouble(fields[4]);
double loeuf = parseDouble(fields[3]);
double loeufLower = parseDouble(fields[4]);
double loeufUpper = parseDouble(fields[5]);
return new GeneConstraint(geneSymbol, transcriptId, pLI, loeuf, loeufLower, loeufUpper);
double loeufLower = parseDouble(fields[5]);
double loeufUpper = parseDouble(fields[6]);
double missenseZ = parseDouble(fields[7]);
double synonymousZ = parseDouble(fields[8]);
return new GeneConstraint(geneSymbol, transcriptId, pLI, loeuf, loeufLower, loeufUpper, missenseZ, synonymousZ);
}

private static double parseDouble(String field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private void assignPVS1(AcmgEvidence.Builder acmgEvidenceBuilder, VariantEvaluat
// • Use caution with splice variants that are predicted to lead to exon skipping but leave the remainder of the protein intact
// • Use caution in the presence of multiple transcripts

GeneConstraint geneContraint = GeneConstraints.geneContraint(variantEvaluation.getGeneSymbol());
GeneConstraint geneContraint = GeneConstraints.geneConstraint(variantEvaluation.getGeneSymbol());
// Should this be using the hasCompatibleDiseaseMatches variable?
boolean inGeneWithKnownDiseaseAssociations = !knownDiseases.isEmpty();
if (inGeneWithKnownDiseaseAssociations && isLossOfFunctionEffect(variantEvaluation.getVariantEffect())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private List<Object> buildVariantRecord(int rank, VariantEvaluation ve, GeneScor
fields.add(clinVarData.getVariationId());
fields.add(clinVarData.getPrimaryInterpretation());
fields.add(clinVarData.starRating());
GeneConstraint geneConstraint = GeneConstraints.geneContraint(geneIdentifier.getGeneSymbol());
GeneConstraint geneConstraint = GeneConstraints.geneConstraint(geneIdentifier.getGeneSymbol());
fields.add(geneConstraint == null ? "" : geneConstraint.loeuf());
fields.add(geneConstraint == null ? "" : geneConstraint.loeufLower());
fields.add(geneConstraint == null ? "" : geneConstraint.loeufUpper());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private List<Object> buildVariantRecord(int rank, VariantEvaluation ve, GeneScor
fields.add(clinVarData.getVariationId());
fields.add(clinVarData.getPrimaryInterpretation());
fields.add(clinVarData.starRating());
GeneConstraint geneConstraint = GeneConstraints.geneContraint(geneIdentifier.getGeneSymbol());
GeneConstraint geneConstraint = GeneConstraints.geneConstraint(geneIdentifier.getGeneSymbol());
fields.add(geneConstraint == null ? "" : geneConstraint.loeuf());
fields.add(geneConstraint == null ? "" : geneConstraint.loeufLower());
fields.add(geneConstraint == null ? "" : geneConstraint.loeufUpper());
Expand Down
Loading

0 comments on commit 55a73b7

Please sign in to comment.