Example usage for com.lowagie.text Table addCell

List of usage examples for com.lowagie.text Table addCell

Introduction

In this page you can find the example usage for com.lowagie.text Table addCell.

Prototype


public void addCell(String content) throws BadElementException 

Source Link

Document

Adds a Cell to the Table.

Usage

From source file:jp.ac.utokyo.rcast.karkinos.graph.GetCNVCharts.java

License:Apache License

private static Object cnvSummaryTable(DataSet dataset, int dispFlg) {

    Table table;
    try {//ww  w  . j  a  v  a  2s. c o m

        if (dispFlg == 1) {
            table = new Table(8);
        } else {
            table = new Table(6);
        }
        // header
        table.addCell("chr");
        table.addCell("start");
        table.addCell("end");
        table.addCell("copy number");
        table.addCell("gain/loss");
        table.addCell("num hetro SNP");

        if (dispFlg == 1) {
            table.addCell("AAF");
            table.addCell("BAF");
        }
        // table.addCell("SNP ratio correl");
        // table.addCell("rejected");

        for (CopyNumberInterval cni : dataset.getCopyNumberIntervalList(9)) {

            if (cni.getCopynumber() == dataset.getBaseploidy()) {
                if (cni.getAaf() == dataset.getBaseploidy() / 2) {
                    continue;
                }
            }
            if (dispFlg == 1) {
                if (cni.isAllelic())
                    continue;
                //               if (cni.getCopynumber() == 0)
                //                  continue;
                //               if (cni.getCopynumber() >= 4)
                //                  continue;
            } else if (dispFlg == 2) {
                if (!cni.isAllelic())
                    continue;
                if (cni.getCopynumber() == 0)
                    continue;
                if (cni.isHdeletion())
                    continue;
            } else {
                if (1 <= cni.getCopynumber() && !cni.isHdeletion()) {
                    continue;
                }
                if (cni.getCopynumber() != 0 && cni.isHdeletion()) {
                    continue;
                }

            }
            table.addCell(cni.getChr());
            table.addCell(format(cni.getStart()) + "");
            table.addCell(format(cni.getEnd()) + "");
            table.addCell("n=" + cni.getCopynumber());
            String s = cni.getCopynumber() < 2 ? "loss" : "gain";
            table.addCell(s);
            table.addCell(format(cni.getNoSNP()) + "");

            if (dispFlg == 1) {
                table.addCell(cni.getAaf() + "");
                table.addCell(cni.getBaf() + "");
            }

            // table.addCell(format(cni.getSnpclrrel())+"");
            // table.addCell(cni.getRejected()+"");

        }
        return table;

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;

}

From source file:jp.ac.utokyo.rcast.karkinos.graph.GetReadsStatsChart.java

License:Apache License

private static Object getCaptureCoveageTable(ReadsSummary readsSummary) {
    Table table;
    try {//from  ww w  . j  av a  2 s . c  o  m
        table = new Table(5);

        // row1
        table.addCell("coveage");
        table.addCell("normal count");
        table.addCell("normal %");
        table.addCell("tumor count");
        table.addCell("tumor %");

        DepthCounter nd = readsSummary.getNormalDepth();
        long normaltotal = nd.getTotal();
        Map<Integer, CounterA> mn = nd.getMap();
        DepthCounter td = readsSummary.getTumorDepth();
        long tumortotal = td.getTotal();
        Map<Integer, CounterA> mt = td.getMap();

        Set<Integer> keySet = new TreeSet<Integer>();
        keySet.addAll(mn.keySet());
        keySet.addAll(mt.keySet());

        for (Integer key : keySet) {

            int countNormal = 0;
            float normalP = 0;
            int countTumor = 0;
            float tumorP = 0;

            String s;
            int n = key;
            if (n >= 1000) {
                s = "1000 -";
                // } else if (n >= 300) {
                // s = "" + n + "-" + (n + 99);
            } else if (n >= 10) {
                s = "" + n + "-" + (n + 9);
            } else if (n >= 1) {
                s = "" + n + "-" + (n + 8);
            } else {
                s = "" + n;
            }
            CounterA normal = mn.get(key);
            if (normal != null) {
                countNormal = normal.getCnt();
            }
            CounterA tumor = mt.get(key);
            if (tumor != null) {
                countTumor = tumor.getCnt();
            }
            normalP = (float) (((double) countNormal / (double) normaltotal) * 100);
            tumorP = (float) (((double) countTumor / (double) tumortotal) * 100);

            table.addCell(s);

            table.addCell(format(countNormal));
            table.addCell(format(normalP) + "%");

            table.addCell(format(countTumor));
            table.addCell(format(tumorP) + "%");

        }

        return table;

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}

From source file:jp.ac.utokyo.rcast.karkinos.graph.GetReadsStatsChart.java

License:Apache License

private static Object getLibrarySizeTable(ReadsSummary readsSummary) {

    Table table;
    try {/*w w w.  j  a v  a2 s . c o  m*/
        table = new Table(6);

        // row1
        table.addCell("Library size");
        table.addCell("normal");
        table.addCell("tumor");

        table.addCell("");
        table.addCell(format(readsSummary.getNormalCounter().getMeanInsertSize()));
        table.addCell(format(readsSummary.getTumorCounter().getMeanInsertSize()));
        return table;

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;

}

From source file:jp.ac.utokyo.rcast.karkinos.graph.GetReadsStatsChart.java

License:Apache License

private static Object getChrSummaryTable(ReadsCounter totalc, Map<String, ReadsCounter> datamap) {

    Table table;
    try {//from  w ww . ja va 2  s . com
        table = new Table(6);

        // row1
        table.addCell("chr/");
        table.addCell("on target");
        table.addCell("out of target");
        table.addCell("on tag unique");
        table.addCell("outoftag unique");
        table.addCell("ontag %");

        for (Entry<String, ReadsCounter> entry : datamap.entrySet()) {

            String chrom = entry.getKey();
            //
            boolean usualchrom = usualChrom(chrom);

            ReadsCounter rc = entry.getValue();
            int target = rc.getTotalOnTarget();
            int total = rc.getTotalmap();
            int outoftarget = total - target;
            int totalu = rc.getTotalunique();
            int uniqueoutoftarget = totalu - rc.getTotalUniqueOntarget();

            table.addCell(chrom);
            table.addCell(format(target));
            table.addCell(format(outoftarget));
            table.addCell(format(rc.getTotalUniqueOntarget()));
            table.addCell(format(uniqueoutoftarget));
            table.addCell(format(rc.onTargetParcent()) + "%");

        }

        // write total
        table.addCell("Total");
        ReadsCounter rc = totalc;
        int target = rc.getTotalOnTarget();
        int total = rc.getTotalmap();
        int outoftarget = total - target;
        int totalu = rc.getTotalunique();
        int uniqueoutoftarget = totalu - rc.getTotalUniqueOntarget();
        table.addCell(format(target));
        table.addCell(format(outoftarget));
        table.addCell(format(rc.getTotalUniqueOntarget()));
        table.addCell(format(uniqueoutoftarget));
        table.addCell(format(rc.onTargetParcent()) + "%");

        return table;

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;

}

From source file:jp.ac.utokyo.rcast.karkinos.graph.GetReadsStatsChart.java

License:Apache License

private static Object getSummaryTable(ReadsSummary readsSummary, String readsStat) {

    try {//from  w w  w.j a v a 2  s  . c  om

        ReadsCounter normal = readsSummary.getNormalCounter();
        ReadsCounter tumor = readsSummary.getTumorCounter();

        Table table = new Table(3);
        int[] width = new int[] { 60, 20, 20 };
        table.setWidths(width);

        // row1
        table.addCell("reads stats/");
        table.addCell("normal");
        table.addCell("tumor");

        // // row
        if (readsStat != null) {

            String[] sa = readsStat.split(",");
            String normalfile = sa[0];
            Properties np = getProp(normalfile);
            String tumorfile = sa[1];
            Properties tp = getProp(tumorfile);
            // datamap.put("total", total);
            // datamap.put("passfilter", passfilter);
            // datamap.put("mapped", mapped);
            // datamap.put("nonduplicate", nonduplicate);
            // datamap.put("duplicate", duplicate);
            // //datamap.put("identityLow", identityLow);
            // datamap.put("unique", unique);
            // datamap.put("proper", proper);
            // datamap.put("properOrunique", properOrunique);
            // datamap.put("bincount", 1l);
            // datamap.put("afterrealgin", afterrealgin);
            // datamap.put("identityLow", identityLow);
            String[] keys = new String[] { "total", "passfilter", "mapped", "nonduplicate", "duplicate",
                    "unique", "proper", "properOrunique", "afterrealgin", "identityLow" };
            for (String key : keys) {
                if (np.containsKey(key)) {

                    // row2
                    String kyeDisp = key.replaceAll("Or", " or ");
                    table.addCell(kyeDisp + " tags");
                    table.addCell(format(np.getProperty(key)));
                    table.addCell(format(tp.getProperty(key)));

                    if (key.equals("duplicate")) {

                        try {
                            // row 13
                            table.addCell("duplicate (%)");
                            table.addCell(
                                    format(getParcent(np.getProperty(key), np.getProperty("nonduplicate")))
                                            + "%");
                            table.addCell(
                                    format(getParcent(tp.getProperty(key), tp.getProperty("nonduplicate")))
                                            + "%");
                        } catch (Exception ex) {
                        }
                    }
                }
            }

        }

        // row
        table.addCell("Total used tags");
        table.addCell(format(normal.getTotalmap()));
        table.addCell(format(tumor.getTotalmap()));

        // row4
        table.addCell("Target tags");
        table.addCell(format(normal.getTotalOnTarget()));
        table.addCell(format(tumor.getTotalOnTarget()));
        // row5
        table.addCell("Target unique tags");
        table.addCell(format(normal.getTotalUniqueOntarget()));
        table.addCell(format(tumor.getTotalUniqueOntarget()));

        if (readsSummary.isPairStats()) {

            // row6
            table.addCell("First reads");
            table.addCell(format(normal.getFirstReads()));
            table.addCell(format(tumor.getFirstReads()));
            // row7
            table.addCell("Second reads");
            table.addCell(format(normal.getSecondReads()));
            table.addCell(format(tumor.getSecondReads()));
            // row8
            table.addCell("Both mapped");
            table.addCell(format(normal.getBothmap()));
            table.addCell(format(tumor.getBothmap()));
            // row9
            table.addCell("Proper reads");
            table.addCell(format(normal.getPropermap()));
            table.addCell(format(tumor.getPropermap()));
            // row10
            table.addCell("mean library size");
            table.addCell(format(normal.getMeanInsertSize()));
            table.addCell(format(tumor.getMeanInsertSize()));

        }

        // // row11
        // row 12
        table.addCell("mean depth");
        table.addCell(format(readsSummary.getNormalDepth().getMeanDepth()));
        table.addCell(format(readsSummary.getTumorDepth().getMeanDepth()));

        table.addCell("total covered region");
        table.addCell(format(readsSummary.getNormalDepth().getTotal()));
        table.addCell(format(readsSummary.getTumorDepth().getTotal()));

        // row 13
        table.addCell("On target(%)");
        table.addCell(format(normal.onTargetParcent()) + "%");
        table.addCell(format(tumor.onTargetParcent()) + "%");

        table.addCell("more than X20(%)");
        table.addCell(format(getX20percent(readsSummary.getNormalDepth())) + "%");
        table.addCell(format(getX20percent(readsSummary.getTumorDepth())) + "%");

        table.addCell("mean depth CDS");
        table.addCell(format(readsSummary.getNormalDepth().getMeanCDSDepth()));
        table.addCell(format(readsSummary.getTumorDepth().getMeanCDSDepth()));

        table.addCell("more than X10(%) CDS");
        table.addCell(format(readsSummary.getNormalDepth().getOver10X()) + "%");
        table.addCell(format(readsSummary.getTumorDepth().getOver10X()) + "%");

        table.addCell("more than X20(%) CDS");
        table.addCell(format(readsSummary.getNormalDepth().getOver20X()) + "%");
        table.addCell(format(readsSummary.getTumorDepth().getOver20X()) + "%");

        return table;

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;

}

From source file:jp.ac.utokyo.rcast.karkinos.graph.GetSNVChart.java

License:Apache License

private static List[] getFilterStatsTables(DataSet dataset) {

    List olist = new ArrayList();
    List olistG = new ArrayList();
    Map<Integer, CounterA> sm = new LinkedHashMap<Integer, CounterA>();
    Map<Integer, CounterA> ti = new LinkedHashMap<Integer, CounterA>();

    Map<Integer, CounterA> smsolo = new LinkedHashMap<Integer, CounterA>();
    Map<Integer, CounterA> tisolo = new LinkedHashMap<Integer, CounterA>();

    ////from   ww w . java 2  s.com
    int insersion = 0;
    int delation = 0;
    int totalmutaion = 0;
    //
    Map<String, MutationCounter> mutationCounter = new TreeMap<String, MutationCounter>();
    Map<String, SNPDepthCounter> mutationCounterNormalSNP = new TreeMap<String, SNPDepthCounter>();
    Map<String, SNPDepthCounter> normalmutationCounter = new TreeMap<String, SNPDepthCounter>();
    Map<String, CounterA> chrCounts = new LinkedHashMap<String, CounterA>();

    //      String keys[] = new String[] { "AtoT", "AtoG", "AtoC", "TtoA", "TtoG",
    //            "TtoC", "CtoA", "CtoT", "CtoG", "GtoA", "GtoT", "GtoC" };

    for (String key : GenotypeKeyUtils.keys1) {

        mutationCounter.put(key, new MutationCounter());
        mutationCounterNormalSNP.put(key, new SNPDepthCounter());
        normalmutationCounter.put(key, new SNPDepthCounter());
    }

    int mutationfilterout = 0;
    int indelfilterout = 0;

    for (SNVHolder snv : dataset.getSnvlist()) {

        int flg = snv.getFlg();
        if (flg == PileUP.NormalSNP || flg == PileUP.REGBOTH) {
            char ref = snv.getNormal().getGenomeR();
            char alt = snv.getNormal().getALT();
            String key = ref + "to" + alt;
            key = GenotypeKeyUtils.aggrigateKeys(key);
            SNPDepthCounter counter = null;
            if (normalmutationCounter.containsKey(key)) {
                counter = normalmutationCounter.get(key);
                counter.reg(snv.getNormal().getTotalcnt());
            }
        }
        if (flg == PileUP.NormalSNP) {

            //

            char ref = snv.getNormal().getGenomeR();
            char alt = snv.getNormal().getALT();
            String key = ref + "to" + alt;
            key = GenotypeKeyUtils.aggrigateKeys(key);
            SNPDepthCounter counter = null;
            boolean hetroSNP = snv.getNormal().getRatio() < 0.6;
            if (hetroSNP && mutationCounterNormalSNP.containsKey(key)) {
                counter = mutationCounterNormalSNP.get(key);
                counter.reg(snv.getNormal().getTotalcnt());
            }

        } else if ((flg == PileUP.SomaticMutation) || (flg == PileUP.TumorINDEL)) {

            if (null != snv.getFilterResult()) {

                if (snv.getChr().equals("chr1")) {
                    if (snv.getPos() == 13645209) {
                        System.out.println("here");
                    }
                }
                Set<Integer> filterflgs = snv.getFilterResult().getPassFilterFlg();
                Set<Integer> infoflgs = snv.getFilterResult().getInfoFlg();

                Map<Integer, CounterA> map = (flg == PileUP.SomaticMutation) ? sm : ti;

                Map<Integer, CounterA> mapsolo = (flg == PileUP.SomaticMutation) ? smsolo : tisolo;

                CounterA ca = null;
                if (snv.getFilterResult().isPassFilter()) {

                    if (map.containsKey(PASS_FILTER)) {
                        ca = map.get(PASS_FILTER);
                    } else {
                        ca = new CounterA();
                        map.put(PASS_FILTER, ca);
                    }
                    ca.inc();

                    if (CalcUtils.pass2(snv.getFilterResult())) {

                        addchrCounts(chrCounts, snv.getChr());
                        //
                        CounterA caf = null;
                        if (map.containsKey(PASS_FILTERFinal)) {
                            caf = map.get(PASS_FILTERFinal);
                        } else {
                            caf = new CounterA();
                            map.put(PASS_FILTERFinal, caf);
                        }
                        caf.inc();
                    } else {

                        for (int filterflg : infoflgs) {
                            if (map.containsKey(filterflg)) {
                                ca = map.get(filterflg);
                            } else {
                                ca = new CounterA();
                                map.put(filterflg, ca);
                            }
                            ca.inc();
                        }

                        // filtered by this property only
                        if (infoflgs.size() == 1) {
                            int filterflg = infoflgs.iterator().next();
                            CounterA counter2 = null;
                            if (mapsolo.containsKey(filterflg)) {
                                counter2 = mapsolo.get(filterflg);
                            } else {
                                counter2 = new CounterA();
                                mapsolo.put(filterflg, counter2);
                            }
                            counter2.inc();
                        }

                    }

                    if (flg == PileUP.TumorINDEL) {
                        if (snv.getTumor().isInsersion()) {
                            insersion++;
                        } else {
                            delation++;
                        }

                    } else {
                        char ref = snv.getTumor().getGenomeR();
                        char alt = snv.getTumor().getALT();
                        String key = ref + "to" + alt;
                        key = GenotypeKeyUtils.aggrigateKeys(key);
                        MutationCounter counter = null;
                        if (mutationCounter.containsKey(key)) {
                            counter = mutationCounter.get(key);
                            int copynumber = (int) (snv.getCi().getVaridateVal() * 2);
                            PileUPResult pir = snv.getTumor();
                            float ratio = pir.getRatio();
                            float fpval = (float) snv.getPvalFisher();
                            float normallogodd = snv.getNormal().getRefLogLikeHood();
                            float adgustedmutateodds = (float) snv.getFilterResult().getLogtAjusted();
                            if (fpval == 0) {
                                fpval = 0.0000000000000001f;
                            }
                            float logp = (float) (-1 * Math.log10(fpval));
                            int depth = pir.getTotalcnt();
                            counter.regStat(copynumber, ratio, logp, depth);
                            if (CalcUtils.pass2(snv.getFilterResult())) {
                                counter.regStat2(depth);
                            }
                            totalmutaion++;
                        }
                        // /

                    }

                } else {
                    // filter out
                    if (flg == PileUP.TumorINDEL) {
                        indelfilterout++;
                    } else {
                        mutationfilterout++;
                    }
                    for (int filterflg : filterflgs) {
                        if (map.containsKey(filterflg)) {
                            ca = map.get(filterflg);
                        } else {
                            ca = new CounterA();
                            map.put(filterflg, ca);
                        }
                        ca.inc();
                    }

                    // filtered by this property only
                    if (filterflgs.size() == 1) {
                        int filterflg = filterflgs.iterator().next();
                        CounterA counter2 = null;
                        if (mapsolo.containsKey(filterflg)) {
                            counter2 = mapsolo.get(filterflg);
                        } else {
                            counter2 = new CounterA();
                            mapsolo.put(filterflg, counter2);
                        }
                        counter2.inc();
                    }

                }
            }

        }
    }

    try {

        Table table1 = summarytable(sm, ti, smsolo, tisolo, mutationfilterout, indelfilterout);

        olist.add(table1);
        //

        // //////////////////
        // mutation stat
        Table tablemutation = new Table(3);
        tablemutation.addCell("mutation type");
        tablemutation.addCell("counts");
        tablemutation.addCell("%");

        Set<Entry<String, MutationCounter>> s = mutationCounter.entrySet();
        for (Entry<String, MutationCounter> e : s) {

            tablemutation.addCell(GenotypeKeyUtils.toDispKey(e.getKey()));
            MutationCounter mc = e.getValue();
            int cnt = mc.getTotal();
            float parcent = (float) ((double) cnt * 100 / (double) totalmutaion);
            tablemutation.addCell(String.valueOf(cnt));
            tablemutation.addCell(String.valueOf(parcent) + "%");

        }

        tablemutation.addCell("delation");
        tablemutation.addCell(String.valueOf(delation));
        tablemutation.addCell("-");

        tablemutation.addCell("insertion");
        tablemutation.addCell(String.valueOf(insersion));
        tablemutation.addCell("-");

        olist.add(tablemutation);

        ///chr table
        //
        Table tablechr = new Table(2);
        tablechr.addCell("chr");
        tablechr.addCell("final candidates");
        Set<Entry<String, CounterA>> chrs = chrCounts.entrySet();
        for (Entry<String, CounterA> e : chrs) {

            tablechr.addCell(e.getKey());
            tablechr.addCell("" + e.getValue().getCnt());

        }

        olist.add(tablechr);

        // mutation stat
        Table tableallele = new Table(13);
        tableallele.addCell("type");
        tableallele.addCell("counts(n=1)");
        tableallele.addCell("ratio mean(n=1)");
        tableallele.addCell("ratio sd(n=1)");
        tableallele.addCell("counts(n=2)");
        tableallele.addCell("ratio mean(n=2)");
        tableallele.addCell("ratio sd(n=2)");
        tableallele.addCell("counts(n=3)");
        tableallele.addCell("ratio mean(n=3)");
        tableallele.addCell("ratio sd(n=3)");
        tableallele.addCell("counts(n=4)");
        tableallele.addCell("ratio mean(n=4)");
        tableallele.addCell("ratio sd(n=4)");
        //
        for (Entry<String, MutationCounter> e : s) {

            MutationCounter mc = e.getValue();
            // int cnt = mc.getTotal();
            tableallele.addCell(GenotypeKeyUtils.toDispKey(e.getKey()));
            for (int n = 1; n <= 4; n++) {
                SummaryStatsHolder ssh = mc.getSummaryStatsHolder(n);
                if (null != ssh) {
                    tableallele.addCell(ssh.getRatio().getN() + "");
                    tableallele.addCell(format(ssh.getRatio().getMean()));
                    tableallele.addCell(format(ssh.getRatio().getStandardDeviation()));
                } else {
                    tableallele.addCell("-");
                    tableallele.addCell("-");
                    tableallele.addCell("-");
                }
            }

        }

        olist.add(tableallele);

        // mutation stat
        Table tableallelep = new Table(13);
        tableallelep.addCell("type");
        tableallelep.addCell("counts(n=1)");
        tableallelep.addCell("log(p val) mean(n=1)");
        tableallelep.addCell("log(p val) sd(n=1)");
        tableallelep.addCell("counts(n=2)");
        tableallelep.addCell("log(p val) mean(n=2)");
        tableallelep.addCell("log(p val) sd(n=2)");
        tableallelep.addCell("counts(n=3)");
        tableallelep.addCell("log(p val) mean(n=3)");
        tableallelep.addCell("log(p val) sd(n=3)");
        tableallelep.addCell("counts(n=4)");
        tableallelep.addCell("log(p val) mean(n=4)");
        tableallelep.addCell("log(p val) sd(n=4)");
        //
        for (Entry<String, MutationCounter> e : s) {

            MutationCounter mc = e.getValue();
            // int cnt = mc.getTotal();
            tableallelep.addCell(GenotypeKeyUtils.toDispKey(e.getKey()));
            for (int n = 1; n <= 4; n++) {
                SummaryStatsHolder ssh = mc.getSummaryStatsHolder(n);
                if (null != ssh) {

                    tableallelep.addCell(ssh.getOddsratio().getN() + "");
                    tableallelep.addCell(format(ssh.getOddsratio().getMean()));
                    tableallelep.addCell(format(ssh.getOddsratio().getStandardDeviation()));

                } else {
                    tableallelep.addCell("-");
                    tableallelep.addCell("-");
                    tableallelep.addCell("-");
                }
            }

        }

        olist.add(tableallelep);
        Set<Entry<String, SNPDepthCounter>> sNormal = normalmutationCounter.entrySet();
        DefaultCategoryDataset cdatasetNormal = new DefaultCategoryDataset();

        for (Entry<String, SNPDepthCounter> e : sNormal) {

            SNPDepthCounter sc = e.getValue();
            int lowcnt = sc.getLowdepthcnt();
            cdatasetNormal.addValue(lowcnt, "x1-x2(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));
            int x2count = sc.getX2count();
            cdatasetNormal.addValue(x2count, "x2-x3(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));
            int x3count = sc.getX3count();
            cdatasetNormal.addValue(x3count, "x3-x4(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));
            int x4count = sc.getX2count();
            cdatasetNormal.addValue(x4count, "x4-x5(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));
            int highdepth = sc.getHighdepthcnt();
            cdatasetNormal.addValue(highdepth, "< x5(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));

        }

        JFreeChart jfcNormal = ChartFactory.createStackedBarChart("normal mutation frequency", "mutation",
                "counts", cdatasetNormal, PlotOrientation.VERTICAL, true, false, false);
        jfcNormal.getPlot().setBackgroundPaint(Color.WHITE);
        setSeriespaint(jfcNormal);

        olistG.add(jfcNormal);

        //
        Set<Entry<String, SNPDepthCounter>> sSNP = mutationCounterNormalSNP.entrySet();
        DefaultCategoryDataset cdatasetSNP = new DefaultCategoryDataset();

        for (Entry<String, SNPDepthCounter> e : sSNP) {

            SNPDepthCounter sc = e.getValue();
            int lowcnt = sc.getLowdepthcnt();
            cdatasetSNP.addValue(lowcnt, "x1-x2(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));
            int x2count = sc.getX2count();
            cdatasetSNP.addValue(x2count, "x2-x3(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));
            int x3count = sc.getX3count();
            cdatasetSNP.addValue(x3count, "x3-x4(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));
            int x4count = sc.getX2count();
            cdatasetSNP.addValue(x4count, "x4-x5(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));
            int highdepth = sc.getHighdepthcnt();
            cdatasetSNP.addValue(highdepth, "< x5(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));

        }

        JFreeChart jfcSNP = ChartFactory.createStackedBarChart("normal SNP frequency", "mutation", "counts",
                cdatasetSNP, PlotOrientation.VERTICAL, true, false, false);
        jfcSNP.getPlot().setBackgroundPaint(Color.WHITE);
        setSeriespaint(jfcSNP);

        olistG.add(jfcSNP);

        //
        DefaultCategoryDataset cdataset = new DefaultCategoryDataset();
        for (Entry<String, MutationCounter> e : s) {

            MutationCounter mc = e.getValue();
            int lowcnt = mc.getLowdepthcnt();
            cdataset.addValue(lowcnt, "x1-x2(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));
            int x2count = mc.getX2count();
            cdataset.addValue(x2count, "x2-x3(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));
            int x3count = mc.getX3count();
            cdataset.addValue(x3count, "x3-x4(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));
            int x4count = mc.getX2count();
            cdataset.addValue(x4count, "x4-x5(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));
            int highdepth = mc.getHighdepthcnt();
            cdataset.addValue(highdepth, "< x5(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));

        }

        JFreeChart jfc = ChartFactory.createStackedBarChart("mutation frequency", "mutation", "counts",
                cdataset, PlotOrientation.VERTICAL, true, false, false);
        jfc.getPlot().setBackgroundPaint(Color.WHITE);
        setSeriespaint(jfc);
        olistG.add(jfc);

        //
        DefaultCategoryDataset cdataset2 = new DefaultCategoryDataset();
        for (Entry<String, MutationCounter> e : s) {

            MutationCounter mc = e.getValue();
            int lowcnt = mc.getLowdepthcntH();
            cdataset2.addValue(lowcnt, "x1-x2(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));
            int x2count = mc.getX2countH();
            cdataset2.addValue(x2count, "x2-x3(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));
            int x3count = mc.getX3countH();
            cdataset2.addValue(x3count, "x3-x4(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));
            int x4count = mc.getX2countH();
            cdataset2.addValue(x4count, "x4-x5(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));
            int highdepth = mc.getHighdepthcntH();
            cdataset2.addValue(highdepth, "< x5(" + KarkinosProp.mindepth + ")",
                    GenotypeKeyUtils.toDispKey(e.getKey()));

        }

        JFreeChart jfc2 = ChartFactory.createStackedBarChart("mutation frequency filter2", "mutation", "counts",
                cdataset2, PlotOrientation.VERTICAL, true, false, false);
        jfc2.getPlot().setBackgroundPaint(Color.WHITE);
        setSeriespaint(jfc2);
        olistG.add(jfc2);

        return new List[] { olist, olistG };

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;

}

From source file:jp.ac.utokyo.rcast.karkinos.graph.GetSNVChart.java

License:Apache License

private static Table summarytable(Map<Integer, CounterA> sm, Map<Integer, CounterA> ti,
        Map<Integer, CounterA> smsolo, Map<Integer, CounterA> tisolo, int mutationfilterout, int indelfilterout)
        throws BadElementException {
    Table table = new Table(3);
    ////from  ww w  . ja v  a 2s.  c  o  m
    // row1
    table.addCell("filter type");
    table.addCell("somatic mutation");
    table.addCell("somatic indel");

    // public static final int SNP = 1;
    // public static final int Low_mappability = 5;
    // public static final int Low_complexty = 6;
    // public static final int Low_SNPQual = 7;
    // public static final int Basian_Filteling = 9;
    // public static final int SUPPORTED_READSNG = 19;
    // public static final int SUPPORTED_BY_ONEDirection = 11;
    // public static final int CONTAIN_Reccurent_MISMATCH = 12;
    // public static final int READSENDSONLY = 13;
    // public static final int TooManyMismatchReads = 14;
    // public static final int MutationAtSameCycle = 15;
    //
    table.addCell("Pass filter Filter2");
    table.addCell(getContStr(sm, PASS_FILTERFinal));
    table.addCell(getContStr(ti, PASS_FILTERFinal));

    table.addCell("Pass filter Filter1");
    table.addCell(getContStr(sm, FilterResult.PASS_FILTER));
    table.addCell(getContStr(ti, FilterResult.PASS_FILTER));

    table.addCell("Filtered out total");
    table.addCell(String.valueOf(mutationfilterout));
    table.addCell(String.valueOf(indelfilterout));

    //      table.addCell("High normal TC adjuated ratio");
    //      table.addCell(getContStr(sm, smsolo, FilterResult.High_normal_adjustedRatio));
    //      table.addCell(getContStr(ti, tisolo, FilterResult.High_normal_adjustedRatio));
    //      

    table.addCell("Bayesian filter for normal");
    table.addCell(getContStr(sm, smsolo, FilterResult.INFO_LOW_refOddsRatio));
    table.addCell(getContStr(ti, tisolo, FilterResult.INFO_LOW_refOddsRatio));

    table.addCell("Bayesian filter for tumor");
    table.addCell(getContStr(sm, smsolo, FilterResult.INFO_LOW_tumorOddsRatio));
    table.addCell(getContStr(ti, tisolo, FilterResult.INFO_LOW_tumorOddsRatio));

    table.addCell("Low adjuated allele ratio");
    table.addCell(getContStr(sm, smsolo, FilterResult.INFO_adjustAlleleFreq));
    table.addCell(getContStr(ti, tisolo, FilterResult.INFO_adjustAlleleFreq));

    table.addCell("Low support reads for TP rescued candidate");
    table.addCell(getContStr(sm, smsolo, FilterResult.INFO_adjustLowdepth));
    table.addCell(getContStr(ti, tisolo, FilterResult.INFO_adjustLowdepth));

    table.addCell("min support reads for non cosmic sites");
    table.addCell(getContStr(sm, smsolo, FilterResult.INFO_minimumSupportReads));
    table.addCell(getContStr(ti, tisolo, FilterResult.INFO_minimumSupportReads));

    table.addCell("Low TC adjuated ratio");
    table.addCell(getContStr(sm, smsolo, FilterResult.Low_tumor_adjustedRatio));
    table.addCell(getContStr(ti, tisolo, FilterResult.Low_tumor_adjustedRatio));

    table.addCell("Low AF in AF depth matrix");
    table.addCell(getContStr(sm, smsolo, FilterResult.Low_tumor_adjustedReads));
    table.addCell(getContStr(ti, tisolo, FilterResult.Low_tumor_adjustedReads));

    table.addCell("High low base quality reads ratio");
    table.addCell(getContStr(sm, smsolo, FilterResult.HighLowQualReads));
    table.addCell(getContStr(ti, tisolo, FilterResult.HighLowQualReads));

    table.addCell("dbSNP");
    table.addCell(getContStr(sm, smsolo, FilterResult.SNP));
    table.addCell(getContStr(ti, tisolo, FilterResult.SNP));

    //
    table.addCell("Supported by only one directional reads");
    table.addCell(getContStr(sm, smsolo, SUPPORTED_BY_ONEDirection));
    table.addCell(getContStr(ti, tisolo, FilterResult.SUPPORTED_BY_ONEDirection));

    //
    table.addCell("Support reads contain another recurrent mismatch");
    table.addCell(getContStr(sm, smsolo, FilterResult.CONTAIN_Reccurent_MISMATCH));
    table.addCell(getContStr(ti, tisolo, FilterResult.CONTAIN_Reccurent_MISMATCH));

    table.addCell("Support reads allelic inblance");
    table.addCell(getContStr(sm, smsolo, FilterResult.noStrandSpecific));
    table.addCell(getContStr(ti, tisolo, FilterResult.noStrandSpecific));

    table.addCell("Support reads contain toomany mismatch");
    table.addCell(getContStr(sm, smsolo, FilterResult.TooManyMismatchReads));
    table.addCell(getContStr(ti, tisolo, FilterResult.TooManyMismatchReads));

    //
    table.addCell("Low Mappability ");
    table.addCell(getContStr(sm, smsolo, FilterResult.Low_mappability));
    table.addCell(getContStr(ti, tisolo, FilterResult.Low_mappability));

    table.addCell("Low Map Quality ");
    table.addCell(getContStr(sm, smsolo, FilterResult.Low_MapQuality));
    table.addCell(getContStr(ti, tisolo, FilterResult.Low_MapQuality));

    table.addCell("Low sequence complexty");
    table.addCell(getContStr(sm, smsolo, FilterResult.Low_complexty));
    table.addCell(getContStr(ti, tisolo, FilterResult.Low_complexty));

    table.addCell("illumina Sys Error");
    table.addCell(getContStr(sm, smsolo, FilterResult.illuminaSpecific));
    table.addCell(getContStr(ti, tisolo, FilterResult.illuminaSpecific));

    table.addCell("only softClip support");
    table.addCell(getContStr(sm, smsolo, FilterResult.softClip));
    table.addCell(getContStr(ti, tisolo, FilterResult.softClip));

    table.addCell("Mutation at same Cycle");
    table.addCell(getContStr(sm, smsolo, FilterResult.MutationAtSameCycle));
    table.addCell(getContStr(ti, tisolo, FilterResult.MutationAtSameCycle));

    table.addCell("Fisher test fail p > " + (float) KarkinosProp.Fisher_Thres_For_SNV_Detection);
    table.addCell(getContStr(sm, smsolo, FilterResult.FisherTestFail));
    table.addCell(getContStr(ti, tisolo, FilterResult.FisherTestFail));

    table.addCell("SNV near Indel");
    table.addCell(getContStr(sm, smsolo, FilterResult.NEARINDEL));
    table.addCell(getContStr(ti, tisolo, FilterResult.NEARINDEL));
    return table;
}

From source file:jp.ac.utokyo.rcast.karkinos.graph.GetSNVChart.java

License:Apache License

private static Object getTRTable(DataSet dataset, PeaksInfo pi) {

    AnalyseDist analyseDist = dataset.getAnalyseDist();
    try {// w  ww .j  a v a2s.co m

        Table table = new Table(6);
        // row1
        table.addCell("source");
        table.addCell("tumor purity");
        table.addCell("s.d.");
        table.addCell("#total SNP");
        table.addCell("correl");
        table.addCell("method");
        // row2
        table.addCell("n=1");
        table.addCell(format(analyseDist.getTumorratioFromLOH().getTumorratio()));
        table.addCell(format(analyseDist.getTumorratioFromLOH().getSd() * 0.01));
        table.addCell(format(analyseDist.getTumorratioFromLOH().getNumber()));
        table.addCell(format(analyseDist.getTumorratioFromLOH().getCorrel()));
        table.addCell(analyseDist.getTumorratioFromLOH().getModeStr());

        // row2
        table.addCell("n=3");
        table.addCell(format(analyseDist.getTumorratioFromGAIN().getTumorratio()));
        table.addCell(format(analyseDist.getTumorratioFromGAIN().getSd() * 0.01));
        table.addCell(format(analyseDist.getTumorratioFromGAIN().getNumber()));
        table.addCell(format(analyseDist.getTumorratioFromGAIN().getCorrel()));
        table.addCell(analyseDist.getTumorratioFromGAIN().getModeStr());

        // row2
        table.addCell("somatic");
        table.addCell(format(analyseDist.getTumorratioFromSomatic().getTumorratio()));
        table.addCell(format(analyseDist.getTumorratioFromSomatic().getSd() * 0.01));
        table.addCell(format(analyseDist.getTumorratioFromSomatic().getNumber()));
        table.addCell(format(analyseDist.getTumorratioFromSomatic().getCorrel()));
        table.addCell("from distribution of somatic mutations");

        table.addCell("tumor purity from ploidy matrix");
        table.addCell(format(dataset.getTumorratioFiitiingMatrix()));
        table.addCell("");
        table.addCell("");
        table.addCell("");
        table.addCell("");

        table.addCell("tumor purity from ploidy matrix");
        table.addCell(format(dataset.getTumorratioFiitiingMatrix()));
        table.addCell("");
        table.addCell("");
        table.addCell("");
        table.addCell("");

        table.addCell("ploidy");
        table.addCell(format(pi.getPloidy()));
        table.addCell("");
        table.addCell("");
        table.addCell("");
        table.addCell("");

        table.addCell("tumor purity used");
        table.addCell(format(dataset.getTumorRatio()));
        //

        return table;

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;

}

From source file:jp.ac.utokyo.rcast.karkinos.graph.SNPGraph.java

License:Apache License

private static Object getTable(long snpRecurrent, long snpDiff) {
    Table table;
    try {/*  w ww  .java 2  s .  com*/
        table = new Table(4);
        // row1
        table.addCell("total dbSNP detected in 2n");
        table.addCell("recurrent SNP");
        table.addCell("different SNP");
        table.addCell("% diffrerence SNP");

        table.addCell(format(snpRecurrent + snpDiff));
        table.addCell(format(snpRecurrent));
        table.addCell(format(snpDiff));
        double ratio = ((double) snpDiff / (double) (snpRecurrent + snpDiff)) * 100;
        table.addCell(format(ratio) + "%");

        return table;

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}

From source file:net.bull.javamelody.swing.print.MPdfWriter.java

License:Apache License

/**
 * Effectue le rendu des headers./*from ww  w  .j a  v a  2s  . c om*/
 *
 * @param table
 *           MBasicTable
 * @param datatable
 *           Table
 * @throws BadElementException
 *            e
 */
protected void renderHeaders(final MBasicTable table, final Table datatable) throws BadElementException {
    final int columnCount = table.getColumnCount();
    final TableColumnModel columnModel = table.getColumnModel();
    // size of columns
    float totalWidth = 0;
    for (int i = 0; i < columnCount; i++) {
        totalWidth += columnModel.getColumn(i).getWidth();
    }
    final float[] headerwidths = new float[columnCount];
    for (int i = 0; i < columnCount; i++) {
        headerwidths[i] = 100f * columnModel.getColumn(i).getWidth() / totalWidth;
    }
    datatable.setWidths(headerwidths);
    datatable.setWidth(100f);

    // table header
    final com.lowagie.text.Font font = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD);
    datatable.getDefaultCell().setBorderWidth(2);
    datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    // datatable.setDefaultCellGrayFill(0.75f);

    String text;
    Object value;
    for (int i = 0; i < columnCount; i++) {
        value = columnModel.getColumn(i).getHeaderValue();
        text = value != null ? value.toString() : "";
        datatable.addCell(new Phrase(text, font));
    }
    // end of the table header
    datatable.endHeaders();
}