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")
|
||||
public String indelNoveltyRate = "NA";
|
||||
|
||||
@DataPoint(description="Histogram of allele frequencies for most common alternate allele")
|
||||
AFHistogram AFhistogramMax = new AFHistogram();
|
||||
@DataPoint(description="Histogram of allele frequencies for most common SNP alternate allele")
|
||||
AFHistogram AFhistogramMaxSnp = new AFHistogram();
|
||||
|
||||
@DataPoint(description="Histogram of allele frequencies for less common alternate alleles")
|
||||
AFHistogram AFhistogramMin = new AFHistogram();
|
||||
@DataPoint(description="Histogram of allele frequencies for less common SNP alternate alleles")
|
||||
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
|
||||
*/
|
||||
static class AFHistogram implements TableType {
|
||||
private Object[] colKeys, rowKeys = {"pairwise_AF"};
|
||||
private Object[] rowKeys, colKeys = {"count"};
|
||||
private int[] AFhistogram;
|
||||
|
||||
private static final double AFincrement = 0.01;
|
||||
private static final int numBins = (int)(1.00 / AFincrement);
|
||||
|
||||
public AFHistogram() {
|
||||
colKeys = initColKeys();
|
||||
AFhistogram = new int[colKeys.length];
|
||||
rowKeys = initRowKeys();
|
||||
AFhistogram = new int[rowKeys.length];
|
||||
}
|
||||
|
||||
public Object[] getColumnKeys() {
|
||||
|
|
@ -121,10 +127,10 @@ public class MultiallelicSummary extends VariantEvaluator { // implements Standa
|
|||
}
|
||||
|
||||
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);
|
||||
for ( double a = 0.00; a <= 1.01; a += AFincrement ) {
|
||||
keyList.add(String.format("%.2f", a));
|
||||
|
|
@ -164,6 +170,7 @@ public class MultiallelicSummary extends VariantEvaluator { // implements Standa
|
|||
nMultiSNPs++;
|
||||
calculatePairwiseTiTv(eval);
|
||||
calculateSNPPairwiseNovelty(eval, comp);
|
||||
updateAFhistogram(eval, AFhistogramMaxSnp, AFhistogramMinSnp);
|
||||
}
|
||||
break;
|
||||
case INDEL:
|
||||
|
|
@ -171,13 +178,13 @@ public class MultiallelicSummary extends VariantEvaluator { // implements Standa
|
|||
if ( !eval.isBiallelic() ) {
|
||||
nMultiIndels++;
|
||||
calculateIndelPairwiseNovelty(eval, comp);
|
||||
updateAFhistogram(eval, AFhistogramMaxIndel, AFhistogramMinIndel);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new UserException.BadInput("Unexpected variant context type: " + eval);
|
||||
}
|
||||
updateAFhistogram(eval);
|
||||
|
||||
|
||||
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 updateAFhistogram(VariantContext vc) {
|
||||
private void updateAFhistogram(VariantContext vc, AFHistogram max, AFHistogram min) {
|
||||
|
||||
final Object obj = vc.getAttribute(VCFConstants.ALLELE_FREQUENCY_KEY, null);
|
||||
if ( obj == null || !(obj instanceof List) )
|
||||
|
|
@ -222,9 +229,9 @@ public class MultiallelicSummary extends VariantEvaluator { // implements Standa
|
|||
}
|
||||
|
||||
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++ )
|
||||
AFhistogramMin.update(AFs.get(i));
|
||||
min.update(AFs.get(i));
|
||||
}
|
||||
|
||||
private final String noveltyRate(final int all, final int known) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue