Transpose rows/cols in AF table to make it molten (so I can plot easily in R)
This commit is contained in:
parent
fbbd04621d
commit
91897f5fe7
|
|
@ -91,25 +91,31 @@ public class MultiallelicSummary extends VariantEvaluator { // implements Standa
|
||||||
//@DataPoint(description = "Multi-allelic Indel Novelty Rate")
|
//@DataPoint(description = "Multi-allelic Indel Novelty Rate")
|
||||||
public String indelNoveltyRate = "NA";
|
public String indelNoveltyRate = "NA";
|
||||||
|
|
||||||
@DataPoint(description="Histogram of allele frequencies for most common alternate allele")
|
@DataPoint(description="Histogram of allele frequencies for most common SNP alternate allele")
|
||||||
AFHistogram AFhistogramMax = new AFHistogram();
|
AFHistogram AFhistogramMaxSnp = new AFHistogram();
|
||||||
|
|
||||||
@DataPoint(description="Histogram of allele frequencies for less common alternate alleles")
|
@DataPoint(description="Histogram of allele frequencies for less common SNP alternate alleles")
|
||||||
AFHistogram AFhistogramMin = new AFHistogram();
|
AFHistogram AFhistogramMinSnp = new AFHistogram();
|
||||||
|
|
||||||
|
@DataPoint(description="Histogram of allele frequencies for most common Indel alternate allele")
|
||||||
|
AFHistogram AFhistogramMaxIndel = new AFHistogram();
|
||||||
|
|
||||||
|
@DataPoint(description="Histogram of allele frequencies for less common Indel alternate alleles")
|
||||||
|
AFHistogram AFhistogramMinIndel = new AFHistogram();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* AF histogram table object
|
* AF histogram table object
|
||||||
*/
|
*/
|
||||||
static class AFHistogram implements TableType {
|
static class AFHistogram implements TableType {
|
||||||
private Object[] colKeys, rowKeys = {"pairwise_AF"};
|
private Object[] rowKeys, colKeys = {"count"};
|
||||||
private int[] AFhistogram;
|
private int[] AFhistogram;
|
||||||
|
|
||||||
private static final double AFincrement = 0.01;
|
private static final double AFincrement = 0.01;
|
||||||
private static final int numBins = (int)(1.00 / AFincrement);
|
private static final int numBins = (int)(1.00 / AFincrement);
|
||||||
|
|
||||||
public AFHistogram() {
|
public AFHistogram() {
|
||||||
colKeys = initColKeys();
|
rowKeys = initRowKeys();
|
||||||
AFhistogram = new int[colKeys.length];
|
AFhistogram = new int[rowKeys.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] getColumnKeys() {
|
public Object[] getColumnKeys() {
|
||||||
|
|
@ -121,10 +127,10 @@ public class MultiallelicSummary extends VariantEvaluator { // implements Standa
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getCell(int row, int col) {
|
public Object getCell(int row, int col) {
|
||||||
return AFhistogram[col];
|
return AFhistogram[row];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Object[] initColKeys() {
|
private static Object[] initRowKeys() {
|
||||||
ArrayList<String> keyList = new ArrayList<String>(numBins + 1);
|
ArrayList<String> keyList = new ArrayList<String>(numBins + 1);
|
||||||
for ( double a = 0.00; a <= 1.01; a += AFincrement ) {
|
for ( double a = 0.00; a <= 1.01; a += AFincrement ) {
|
||||||
keyList.add(String.format("%.2f", a));
|
keyList.add(String.format("%.2f", a));
|
||||||
|
|
@ -164,6 +170,7 @@ public class MultiallelicSummary extends VariantEvaluator { // implements Standa
|
||||||
nMultiSNPs++;
|
nMultiSNPs++;
|
||||||
calculatePairwiseTiTv(eval);
|
calculatePairwiseTiTv(eval);
|
||||||
calculateSNPPairwiseNovelty(eval, comp);
|
calculateSNPPairwiseNovelty(eval, comp);
|
||||||
|
updateAFhistogram(eval, AFhistogramMaxSnp, AFhistogramMinSnp);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INDEL:
|
case INDEL:
|
||||||
|
|
@ -171,13 +178,13 @@ public class MultiallelicSummary extends VariantEvaluator { // implements Standa
|
||||||
if ( !eval.isBiallelic() ) {
|
if ( !eval.isBiallelic() ) {
|
||||||
nMultiIndels++;
|
nMultiIndels++;
|
||||||
calculateIndelPairwiseNovelty(eval, comp);
|
calculateIndelPairwiseNovelty(eval, comp);
|
||||||
|
updateAFhistogram(eval, AFhistogramMaxIndel, AFhistogramMinIndel);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new UserException.BadInput("Unexpected variant context type: " + eval);
|
throw new UserException.BadInput("Unexpected variant context type: " + eval);
|
||||||
}
|
}
|
||||||
updateAFhistogram(eval);
|
|
||||||
|
|
||||||
return null; // we don't capture any interesting sites
|
return null; // we don't capture any interesting sites
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -209,7 +216,7 @@ public class MultiallelicSummary extends VariantEvaluator { // implements Standa
|
||||||
private void calculateIndelPairwiseNovelty(VariantContext eval, VariantContext comp) {
|
private void calculateIndelPairwiseNovelty(VariantContext eval, VariantContext comp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAFhistogram(VariantContext vc) {
|
private void updateAFhistogram(VariantContext vc, AFHistogram max, AFHistogram min) {
|
||||||
|
|
||||||
final Object obj = vc.getAttribute(VCFConstants.ALLELE_FREQUENCY_KEY, null);
|
final Object obj = vc.getAttribute(VCFConstants.ALLELE_FREQUENCY_KEY, null);
|
||||||
if ( obj == null || !(obj instanceof List) )
|
if ( obj == null || !(obj instanceof List) )
|
||||||
|
|
@ -222,9 +229,9 @@ public class MultiallelicSummary extends VariantEvaluator { // implements Standa
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(AFs);
|
Collections.sort(AFs);
|
||||||
AFhistogramMax.update(AFs.get(AFs.size()-1));
|
max.update(AFs.get(AFs.size()-1));
|
||||||
for ( int i = 0; i < AFs.size() - 1; i++ )
|
for ( int i = 0; i < AFs.size() - 1; i++ )
|
||||||
AFhistogramMin.update(AFs.get(i));
|
min.update(AFs.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String noveltyRate(final int all, final int known) {
|
private final String noveltyRate(final int all, final int known) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue