public class SeqLogoPlotter extends Object
DNAAlphabet.
In general, sequence logos can be plotted to any Graphics2D object, e.g., for on-screen printing using the plotLogo methods.
For convenience, the method plotLogoToPNG(String, int, double[][]) can be used to directly plot a sequence logo
to a PNG file with a given height and automatically chosen aspect ratio.| Modifier and Type | Class and Description |
|---|---|
static class |
SeqLogoPlotter.SeqLogoPlotGenerator
PlotGeneratorResult.PlotGenerator for plotting sequence logos. |
| Constructor and Description |
|---|
SeqLogoPlotter() |
| Modifier and Type | Method and Description |
|---|---|
static Pair<BufferedImage,Graphics2D> |
getBufferedImageAndGraphics(int height,
double[][] ps)
Creates a new
BufferedImage with given height and width chosen automatically according to the number of rows
of ps, and returns this BufferedImage and its Graphics2D object. |
static int |
getColumnWidth(int height)
Returns the width of one column in the sequence logo of the given height for a PWM with the given number of columns.
|
static int |
getHeight(int width,
double[][] ps)
Returns the automatically chosen height for a given width and position weight matrix.
|
static int |
getHeightForDependencyLogo(int seqLength,
int numSeqs,
int[] chunkHeights,
int width,
int blockSpacer)
Returns the height for a dependency logos of the given sequence length and chunks.
|
static double |
getICScale(double[] p)
Returns the information content scaled to [0,1].
|
static int |
getWidth(int height,
double[][] ps)
Returns the automatically chosen width for a given height and position weight matrix.
|
static int |
getWidth(int height,
int numCol)
Returns the width of a sequence logo of the given height for a PWM with the given number of columns.
|
static BufferedImage |
plotDefaultDependencyLogoToBufferedImage(DataSet data,
double[] weights,
int width)
Plots a dependency logo using default parameters to a
BufferedImage. |
static void |
plotDefaultDependencyLogoToGraphicsAdaptor(GraphicsAdaptor ga,
DataSet data,
double[] weights,
int width)
Plots a dependency logo using default parameters to a
GraphicsAdaptor. |
static int |
plotDependencyLogo(DataSet seqs,
Object[] labels,
int ticPeriod,
double[][] classProbs,
double[] weights,
Graphics2D graph,
int width,
int offx,
int offy,
int[] numPerChunk,
int[] chunkHeights,
double minPercent,
int logoHeight,
boolean highlightMaxDeps,
int numBestForSorting,
boolean sortGlobally,
boolean sortByWeights,
boolean scaleByDeps,
double threshold)
Plots a dependency logo using the supplied parameters.
|
protected static void |
plotLogo(Graphics2D g,
double x,
double y,
double w,
double h,
double[] p)
Plots a sequence logo for a single position to a graphics object.
|
static void |
plotLogo(Graphics2D g,
int h,
double[][] ps)
Plots the sequence logo for the position weight matrix given in
ps. |
static void |
plotLogo(Graphics2D g,
int height,
double[][] ps,
String[] labels,
String labX,
String labY)
Plots the sequence logo for the position weight matrix given in
ps. |
static void |
plotLogo(Graphics2D g,
int w,
int h,
double[][] ps,
String[] labels,
String labX,
String labY)
Plots the sequence logo for the position weight matrix given in
ps. |
static void |
plotLogo(Graphics2D g,
int x,
int y,
int w,
int h,
double[][] ps,
String[] labels,
String labX,
String labY)
Plots the sequence logo for the position weight matrix given in
ps. |
static BufferedImage |
plotLogoToBufferedImage(int height,
double[][] ps)
Plots the sequence logo for the position weight matrix given in
ps. |
static void |
plotLogoToPNG(String path,
int height,
double[][] ps)
Plots the sequence logo for the position weight matrix given in
ps. |
static void |
plotTALgetterLogo(Graphics2D g,
int x,
int y,
int w,
int h,
double[][] ps,
double[] imp,
String[] labels,
String labX,
String labY,
String labY2)
Plots the TALgetter logo for the binding specificities given in
ps. |
static BufferedImage |
plotTALgetterLogoToBufferedImage(int height,
double[][] ps,
double[] imp,
String[] lab)
Plots the TALgetter logo for the binding specificities given in
ps. |
static void |
plotTALgetterLogoToPNG(String path,
int height,
double[][] ps,
double[] imp,
String[] lab)
Plots the TALgetter logo for the binding specificities given in
ps. |
public static int getHeightForDependencyLogo(int seqLength,
int numSeqs,
int[] chunkHeights,
int width,
int blockSpacer)
seqLength - the sequence lengthnumSeqs - the number of sequenceschunkHeights - the heights of the different chunkswidth - the width of the total dependency logoblockSpacer - the block spacer, i.e., the height of the space, where sequence logos are plottedpublic static BufferedImage plotDefaultDependencyLogoToBufferedImage(DataSet data, double[] weights, int width) throws Exception
BufferedImage.data - the sequencesweights - the weights of the sequenceswidth - the width of the imageException - if the logo could not be plottedpublic static void plotDefaultDependencyLogoToGraphicsAdaptor(GraphicsAdaptor ga, DataSet data, double[] weights, int width) throws Exception
GraphicsAdaptor.ga - the graphics adaptordata - the sequencesweights - the weights of the sequenceswidth - the width of the imageException - if the logo could not be plottedpublic static int plotDependencyLogo(DataSet seqs, Object[] labels, int ticPeriod, double[][] classProbs, double[] weights, Graphics2D graph, int width, int offx, int offy, int[] numPerChunk, int[] chunkHeights, double minPercent, int logoHeight, boolean highlightMaxDeps, int numBestForSorting, boolean sortGlobally, boolean sortByWeights, boolean scaleByDeps, double threshold) throws Exception
seqs - the sequenceslabels - the labels on the x-axisticPeriod - the period of the tick marks, i.e., only the ticPeriod-th label is shownclassProbs - the class probabilities for the sequences. If supplied, explaining away residual (see BTExplainingAwayResidual) is used for computing edges representing dependencies. If null, mutual information is used.weights - the weights of the sequencesgraph - the graphics object to which is plottedwidth - the width of the dependency logooffx - the offset in x directionoffy - the offset in y directionnumPerChunk - the number of sequences in each chunkchunkHeights - the height of the plots representing those chunksminPercent - the minimum percentage of sequences that may make up a partitionlogoHeight - the height of the sequence logo plotshighlightMaxDeps - if true, the maximum dependencies of each position are highlighted in rednumBestForSorting - the number of position used for sorting partitionssortGlobally - if true sorting positions are used globally (instead of partition-wise, recursively)sortByWeights - if true, partitions are sorted by average weight of the contained sequences, otherwise by nucleotide abundancesscaleByDeps - if true, edges representing dependencies are shaded according to the dependency value, otherwise by p-valuesthreshold - the threshold on the dependency measure that leads to further partitioning (if size is sufficient)Exception - if the logo could not be plottedpublic static void plotLogoToPNG(String path, int height, double[][] ps) throws IOException
ps.
The rows of ps correspond to positions in the sequence logo. Each row must be normalized.
For a given height (in pixels), the width is chosen automatically depending on the number of rows
in ps.
The positions of the sequence logo are numbered contiguously from 1 to ps.length. The label of the
x-axis is set to "Position", and the label of the y-axis is set to "bits".
The sequence logo is written to the PNG file given in path.path - the path to the PNG file writtenheight - the height of the PNG image (in pixels)ps - the position weight matrixIOException - if the file could not be writtenpublic static BufferedImage plotLogoToBufferedImage(int height, double[][] ps)
ps.
The rows of ps correspond to positions in the sequence logo. Each row must be normalized.
For a given height (in pixels), the width is chosen automatically depending on the number of rows
in ps.
The positions of the sequence logo are numbered contiguously from 1 to ps.length. The label of the
x-axis is set to "Position", and the label of the y-axis is set to "bits".
The sequence logo is return as a BufferedImage.height - the height of the PNG image (in pixels)ps - the position weight matrixpublic static Pair<BufferedImage,Graphics2D> getBufferedImageAndGraphics(int height, double[][] ps)
BufferedImage with given height and width chosen automatically according to the number of rows
of ps, and returns this BufferedImage and its Graphics2D object.height - the height (in pixels)ps - the position weight matrixBufferedImage and its Graphics2D objectpublic static void plotLogo(Graphics2D g, int h, double[][] ps)
ps.
The rows of ps correspond to positions in the sequence logo. Each row must be normalized.
For a given height (in pixels), the width is chosen automatically depending on the number of rows
in ps.
The positions of the sequence logo are numbered contiguously from 1 to ps.length. The label of the
x-axis is set to "Position", and the label of the y-axis is set to "bits".
The sequence logo is written to the Graphics2D object given in g.g - the Graphics2D objecth - the height of the sequence logops - the position weight matrixpublic static void plotLogo(Graphics2D g, int height, double[][] ps, String[] labels, String labX, String labY)
ps.
The rows of ps correspond to positions in the sequence logo. Each row must be normalized.
For a given height (in pixels), the width is chosen automatically depending on the number of rows
in ps.
The sequence logo is written to the Graphics2D object given in g.g - the Graphics2D objectheight - the height of the sequence logops - the position weight matrixlabels - the labels of the positions of the sequence logo, if null the positions are numbered contiguously from 1 to ps.lengthlabX - the label of the x-axislabY - the label of the y-axispublic static int getWidth(int height,
double[][] ps)
height - the heightps - the position weight matrixpublic static int getWidth(int height,
int numCol)
height - the heightnumCol - the number of columnspublic static int getColumnWidth(int height)
height - the heightpublic static int getHeight(int width,
double[][] ps)
width - the widthps - the position weight matrixpublic static void plotLogo(Graphics2D g, int w, int h, double[][] ps, String[] labels, String labX, String labY)
ps.
The rows of ps correspond to positions in the sequence logo. Each row must be normalized.
The sequence logo is written to the Graphics2D object given in g.g - the Graphics2D objectw - the width of the sequence logoh - the height of the sequence logops - the position weight matrixlabels - the labels of the positions of the sequence logo, if null the positions are numbered contiguously from 1 to ps.lengthlabX - the label of the x-axislabY - the label of the y-axispublic static void plotLogo(Graphics2D g, int x, int y, int w, int h, double[][] ps, String[] labels, String labX, String labY)
ps.
The rows of ps correspond to positions in the sequence logo. Each row must be normalized.
The sequence logo is written to the Graphics2D object given in g.g - the Graphics2D objectx - the x-coordinate of the bottom left corner of the sequence logoy - the y-coordinate of the bottom left corner of the sequence logo (-h results in a sequence logo spanning from 0 to h)w - the width of the sequence logoh - the height of the sequence logops - the position weight matrixlabels - the labels of the positions of the sequence logo, if null the positions are numbered contiguously from 1 to ps.lengthlabX - the label of the x-axislabY - the label of the y-axispublic static void plotTALgetterLogoToPNG(String path, int height, double[][] ps, double[] imp, String[] lab) throws IOException
ps.
The rows of ps correspond to specificities of the RVDs. Each row must be normalized.
For a given height (in pixels), the width is chosen automatically depending on the number of rows
in ps. In addition, the importance of RVDs is plotted as given in imp.
The labels of the RVDs are given in lab. The label of the
x-axis is set to "RVD", and the label of the y-axes are set to "bits" and "Importance", respectively.
The TALgetter logo is written to the PNG file given in path.path - the path to the PNG file writtenheight - the height of the PNG image (in pixels)ps - the binding specificities of RVDsimp - the importance of RVDslab - the amino acids of the RVDs in one-letter codeIOException - if the file could not be writtenpublic static BufferedImage plotTALgetterLogoToBufferedImage(int height, double[][] ps, double[] imp, String[] lab)
ps.
The rows of ps correspond to specificities of the RVDs. Each row must be normalized.
For a given height (in pixels), the width is chosen automatically depending on the number of rows
in ps. In addition, the importance of RVDs is plotted as given in imp.
The labels of the RVDs are given in lab. The label of the
x-axis is set to "RVD", and the label of the y-axes are set to "bits" and "Importance", respectively.
The TALgetter logo is returned as BufferedImage.height - the height of the PNG image (in pixels)ps - the binding specificities of RVDsimp - the importance of RVDslab - the amino acids of the RVDs in one-letter codepublic static void plotTALgetterLogo(Graphics2D g, int x, int y, int w, int h, double[][] ps, double[] imp, String[] labels, String labX, String labY, String labY2)
ps.
The rows of ps correspond to specificities of the RVDs. Each row must be normalized.
For a given height (in pixels), the width is chosen automatically depending on the number of rows
in ps. In addition, the importance of RVDs is plotted as given in imp.
The labels of the RVDs are given in lab. The label of the
x-axis is set to "RVD", and the label of the y-axes are set to "bits" and "Importance", respectively.
The TALgetter logo is returned as BufferedImage.g - the Graphics2D objectx - the x-coordinate of the bottom left corner of the TALgetter logoy - the y-coordinate of the bottom left corner of the TALgetter logo (-h results in a logo spanning from 0 to h)w - the width of the TALgetter logoh - the height of the TALgetter logops - the binding specificities of RVDsimp - the importance of RVDslabels - the amino acids of the RVDs in one-letter codelabX - the label of the x-axislabY - the label of the y-axislabY2 - the label of the second (importance) y-axisprotected static void plotLogo(Graphics2D g, double x, double y, double w, double h, double[] p)
g - the graphics objectx - the x positiony - the y positionw - the widthh - the heightp - the probabilitiespublic static double getICScale(double[] p)
p - the probabilities