Skip to content

Commit

Permalink
Add refpanel option to limit allowed allele switches (#132)
Browse files Browse the repository at this point in the history
* Add refpanel option to limit allowed allele switches

* Update allele switches messages
  • Loading branch information
seppinho authored Feb 8, 2024
1 parent 4227800 commit 17ce543
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public boolean run(WorkflowContext context) {
double sampleCallrate = panel.getQcFilterByKey("sampleCallrate");
double mixedGenotypesChrX = panel.getQcFilterByKey("mixedGenotypeschrX");
int strandFlips = (int) (panel.getQcFilterByKey("strandFlips"));
int alleleSwitches = (int) (panel.getQcFilterByKey("alleleSwitches"));
String ranges = panel.getRange();

if (ranges != null) {
Expand Down Expand Up @@ -336,6 +337,15 @@ else if (task.getStrandFlipSimple() + task.getStrandFlipAndAlleleSwitch() > stra
return false;
}

// Check if too many allele switches are detected
else if (task.getAlleleSwitch() > alleleSwitches) {
text.append("<br><b>Error:</b> More than " + alleleSwitches
+ " allele switches have been detected. Imputation cannot be started!");
context.error(text.toString());

return false;
}

else if (task.isChrXMissingRate()) {
text.append(
"<br><b>Error:</b> Chromosome X nonPAR region includes > 10 % mixed genotypes. Imputation cannot be started!");
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/genepi/imputationserver/util/RefPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

public class RefPanel {

public static final String ALLELE_SWITCHES = String.valueOf(Integer.MAX_VALUE);
public static final String STRAMD_FLIPS = "100";
public static final String SAMPLE_CALL_RATE = "0.5";
public static final String MIN_SNPS = "3";
Expand Down Expand Up @@ -57,6 +58,7 @@ public RefPanel() {
defaultQcFilter.put("sampleCallrate", SAMPLE_CALL_RATE);
defaultQcFilter.put("mixedGenotypeschrX", CHR_X_MIXED_GENOTYPES);
defaultQcFilter.put("strandFlips", STRAMD_FLIPS);
defaultQcFilter.put("alleleSwitches", ALLELE_SWITCHES);
}

public String getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,47 @@ public void testQcStatisticsDontAllowStrandFlips() throws IOException {
"<b>Error:</b> More than -1 obvious strand flips have been detected. Please check strand. Imputation cannot be started!"));

}

public void testQcStatisticsAllowAlleleSwitches() throws IOException {

String configFolder = "test-data/configs/hapmap-3chr";
String inputFolder = "test-data/data/simulated-chip-3chr-imputation-switches";

// create workflow context
WorkflowTestContext context = buildContext(inputFolder, "hapmap2");

// create step instance
FastQualityControlMock qcStats = new FastQualityControlMock(configFolder);

// run and test
boolean result = run(context, qcStats);

// check statistics

assertTrue(context.hasInMemory("Excluded sites in total: 2,967"));
assertTrue(context.hasInMemory("Allele switch: 118,209"));
}

public void testQcStatisticsDontAllowAlleleSwitches() throws IOException {

String configFolder = "test-data/configs/hapmap-3chr";
String inputFolder = "test-data/data/simulated-chip-3chr-imputation-switches";

// create workflow context
WorkflowTestContext context = buildContext(inputFolder, "hapmap2-qcfilter-alleleswitches");

// create step instance
FastQualityControlMock qcStats = new FastQualityControlMock(configFolder);

// run and test
boolean result = run(context, qcStats);

// check statistics

assertTrue(context.hasInMemory("Excluded sites in total: 2,967"));
assertTrue(context.hasInMemory("Allele switch: 118,209"));
assertTrue(context.hasInMemory("<b>Error:</b> More than 33 allele switches have been detected. Instructions to solve this issue can be found in our documentation. Imputation cannot be started!"));
}

public void testQcStatisticsFilterOverlap() throws IOException {

Expand Down
14 changes: 14 additions & 0 deletions test-data/configs/hapmap-3chr/panels.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,18 @@ panels:
qcFilter:
sampleCallrate: 1.01
strandFlips: 100

- id: hapmap2-qcfilter-alleleswitches
hdfs: ref-panels/hapmap_r22.chr$chr.CEU.hg19.msav
legend: ref-panels/hapmap_r22.chr$chr.CEU.hg19_impute.legend.gz
mapEagle: ref-panels/genetic_map_hg19_chr1.txt
refEagle: ref-panels/hapmap_r22.eagle/hapmap_r22.chr$chr.CEU.hg19.recode.bcf
samples:
eur: 60
mixed: -1
populations:
eur: EUR
mixed: Mixed
qcFilter:
alleleSwitches: 33

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 17ce543

Please sign in to comment.