NOTE: This Documentation is also available as R Vignette.
chromoMap provides interactive, configurable and elegant
graphics visualization of chromosomes or chromosomal regions allowing
users to map chromosome features (like genes,SNPs etc.) onto the
chromosome and visualize the feature-associated data (like multi-omics
data). Each chromosome is composed of genomic-windows(representing a
specific range determined based on chromosome length) that, on hover,
shows details about the annotations in that locus range. The plots can
be saved as HTML documents that can be shared easily. In addition, you
can include them in R Markdown or in R Shiny applications.
Some of the prominent features of the package are:
chromoMap-DiscreteColorMaps.chromoMap-HeatMaps (for chromsome
heat-maps), chromoMap-Bar (bar plots on chromosomes),
chromoMap-Scatter (scatter plot on chromosomes), and
epi-tags (condition-based tagging of chromosome
genomic-windows).2-Dimensional Chromosome plots.chromLinks plotsThis vignette provide you with a description of how you can use the
various features of chromoMap to create fantastic
annotation plots and visualizing the feature-associated data. If you,
however, want to know more about the applications of the plot, please
check the publication or contact me. I recommend using the
RStudio application since the interactive plots can be
viewed beautifully in the application’s viewer pane and it allows you to
export the plot either as static image or a stand-alone HTML web
page.
chromoMapYou can install the package by just typing the following commands:
The chromoMap can be used to visualize and annotate
chromosomes of any living organism. It is because it renders the
chromosome based on the co-ordinate information that you will provide as
input. So, if you have the genomic co-ordinates of the organism, you can
create chromoMaps for it.
The input data are tab-delimited text files (almost similar to the BED file format). It takes separate files for the chromosomes and the annotations. The input files should not have column headers (however, I have explained each column type below)
This file contains the co-ordinates of the chromosomes. The columns of this file(in order) are described below (all columns are mandatory unless specified optional):
I have developed algorithm that will include both start and end coordinates of chromosomes so that users can also be able to visualize a region of chromosome (not necessarily starting at 1). You can use your imagination to visualize anything that has coordinates( like RNA as well).
Your chromosome file should look like:Once you have chromosome co-ordinates in file, the next thing is to have data for annotation. annotation elements/features could be anything that has co-ordinates like genes,SNPS, etc., and associated data, like gene-expression, methylation etc. The annotation-data is also provided in the same format.
your annotation file should look like:
To prevent you from making some possible errors, here are a few points to care about while preparing files:
TIP: You can use MS excel to create your files and then use save as tab-delimited option.
For the plots in this vignette, I will be using synthetic chromosome and annotation files.
# chromosome files
chr_file_1 = "chr_file_without_centromere.txt"
chr_file_2 = "chr_file_with_centromere.txt"
# annotation files
anno_file_1 = "annotation_pos.txt"
anno_file_2 = "annotation_pos_and_neg.txt"NOTE: I have used variables to assign file names. You can directly use the file names strings in the chromoMap( ) function.
Let’s have a look at the data in these files:
chromosome file:
Chromosome file with centromere:
Annotation file with positive data.
head(read.table(anno_file_1,sep = "\t"))
#> V1 V2 V3 V4 V5
#> 1 An1 chr1 558 560 10
#> 2 An2 chr2 396 398 34
#> 3 An3 chr2 281 283 89
#> 4 An4 chr1 125 127 56
#> 5 An5 chr2 406 408 100
#> 6 An6 chr2 340 342 91Annotation file with both positive and negative data.
chromoMap now supports passing R objects directly as
input instead of filenames. The chromosome cordinate input (first
argument) and annotations(second argument) can either be passed as a
character vector specifying the filenames or as a
list of data.frames with one data.frame per ploidy.
# passing data.frames directly instead of files
chromoMap(list(chr.data),list(anno.data))
# for polyploidy
chromoMap(list(chr.data1,chr.data2),
list(anno.data1,anno.data2),ploidy = 2)Note: The format of the data is the same. column names or row names is irrelevant and can be anything but the order should be same as described above (for files).
chromoMapOnce you have your input files ready, begin creating chromosomes plots like a pro. The simple annotation plot can be created using the following command:
#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Visualizing..
This will create a plot with default properties.
that’s it! you have created a simple annotation plot. now hover over the annotated windows to see the magic. you should see a tooltip describing:
If you have added hyperlinks to the elements, you can
click the element labels in tooltip to access the web page.
Tool-tip Toggle: On hover, the tooltip appear on the screen as long as your pointer is over the locus. It will disappear if you move the pointer away. You can click the locus to have a stable tooltip on screen. click again on same or other locus to hide it again.
If you are not satisfied with the default look of the plot(which I’m
sure you wouldn’t), you can play around with some of the properties to
style your plot described under the section ‘configuring
chromoMap’ in this vignette.
Now, let’s create one with centromeres.
#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Visualizing..
Biologically speaking, chromosomes occur in sets. So, just
visualizing a set of chromosome(called as haploid) wouldn’t be
sufficient in some scenarios. Hence, I added the feature of adding sets
of chromosomes as seperate set of files. Don’t forget to set the
ploidy argument to the number of sets you are passing.
#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 2
#> Number of Chromosomes in set 1 : 2
#> Number of Chromosomes in set 2 : 2
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Number of annotations in data set 2 : 200
#> Visualizing..
polyploidy turned out to be a powerful feature that can actually be used in multiple ways. The sets of chromsomes are rendered independent of each other and, hence, can differ in number and size. Using this feature you can visualize polyploid sets, haploid sets of different species on same plot, or even different samples of same species for comparison. Be creative to use this feature to your own requirement. Some interesting examples I have included in my paper.
I have provided two types of annotation algorithms that will visualize the annotations differently. Point annotation will annotate an element on a single locus, ignoring its size. While, the segment-annotation algorithm consider the size and visualize the annotation as a segment.
The default is point-annotation. To use segment annotation set the
argument segment_annotation to TRUE. Segment
annotations will be advantageous in cases like displaying gene
structure.
here’s a hypothetical example(exon regions of the genes g1,g2 and g3).
chromoMap now supports construction of high resolution
maps using by either scaling the number of windows per chromosome or by
choosing arbitrary window size.
chromoMap determines the number of genomic windows (and
their size/range) constructed for each chromosome based on the length of
the chromosomes. By default, 100 windows are created for the longest
chromosome and all other chromosomes will have #windows based on the
proportion of their length to the longest chromosome.
A new feature now allow to scale the number of windows which
consequently reduces the genomic window size. The number of windows will
be a multiple of 100 for the longest chromosome while the #windows for
rest of chromosomes and the window size are algorithmically determined.
Use the argument n_win.factor to increase the scale as
described below. Also, set the argument win.summary.display
to TRUE to output window summary to console.
# default value
library(chromoMap)
chromoMap(chr_file_1,anno_file_1,
n_win.factor = 1,
win.summary.display=T)#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> ########### Window Summary ##########
#> Summary for Ploidy 1
#> Chr nwins min max
#> chr1 100 10 10
#> chr2 70 10 10
#> ####################################
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Visualizing..
In the window summary, ‘nwin’ is number of windows while ‘min’ and ‘max’ is the minimum and maximum size of the window. In cases where chromsomes cannot be split into equal size windows, two window sizes differeing by 1nt are used (as in the following case).
Now, increasing the #windows 3 times #windows for the longest chromsome.
#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> ########### Window Summary ##########
#> Summary for Ploidy 1
#> Chr nwins min max
#> chr1 300 3 4
#> chr2 210 3 4
#> ####################################
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Visualizing..
Alternately, users can now visualize the chromoMap plots
with a fixed window size. In order to use fixed-window method, set the
fixed.window argument to TRUE and then specify
the window.size.
library(chromoMap)
chromoMap(chr_file_1,anno_file_1,
fixed.window = T,
window.size = 5,
win.summary.display = T)#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> ########### Window Summary ##########
#> Summary for Ploidy 1
#> Chr nwins min max
#> chr1 200 5 5
#> chr2 140 5 5
#> ####################################
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Visualizing..
IMPORTANT In fixed window analysis, the last window
of the chromosome will be removed if the chromosome cannot be equally
divided using the given window size. Users can include the last window
by setting the argument remove.last.window to
FALSE. Note that in the case when last windows are
included, the last windows may not be exactly to the scale.
Huge volume of biological data is being produced in today’s world. I
thought it would be nice to visualize the data associated with the
chromosome regions or elements/features. You can do this by creating
data-based color annotation plots in chromoMap. Before
going forward let’s know about the data types chromoMap can handle. You
can use either numeric data or character/categorical data for
annotations. For the type of data type you are using, you need to set
the argument data_type to either numeric or
categorical. Also, to use this category of plot, you need
to set data_based_color_map to TRUE.Now let’s
explore the various types of plots you can create using
chromoMap.
This type of plot can be used if your annotations are categorized into groups. This plot will assign distinct colors to each group. Your annotations file’s data column should have groups assigned to each element as character value.
IMPORTANT: the data_colors argument will specify the
color for each group and must be passed as a list() of vectors. If the
ploidy is 2, two vectors will be passed in list. Hence, you must pass a
vector for each ploidy in a list.
chromoMap("chromosome_file.txt","annotation_file.txt",
data_based_color_map = T,
data_type = "categorical",
data_colors = list(c("orange","yellow")))#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 20
#> Visualizing..
You can now manually set the order of categories by using the
discrete.domain argument which should be passed as vector
with categories as character strings.(e.g discrete.domain =
c("type2","type1") in above example.)
The best thing is, it can also create a legend for each group with labels used by you as group names. [see more under ‘legends’ section]
chromoMap-HeatMaps are chromosome heatmaps that allow
you to visualize feature associated numeric data as heat colors. In your
annotations file, add numeric data in data column.
#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Visualizing..
data_colors can be used to set the heat colors also. It
should be passed as a list of vector(s) with a vector for each
ploidy.
Well, remember that chromosomal locus in the plot is a range, and
more than one elements can be annotated in that range. So, for the data
assignment of the windows where multiple elements are mapped, there is
an aggregation method that allows you to control how data is
aggregated/summarized for a given locus. The data for each locus will be
determined by aggregate_func argument which can take
avg for average (default) ,sum for summation
of data values of all elements mapped on that locus, min ,
max,median and count.
So, if you want to use the sum function:
chromoMap("chromosome_file.txt","annotation_file.txt",
data_based_color_map = T,
data_type = "numeric",
aggregate_func = "sum")You can use the different agregate functions for each ploidy by passing the argument as vector. Hence, for polyploidy, if only one value is passed, this value will be used for all sets.Otherwise, you can specify for each set as:
chromoMap(c("chromosome_file_set_1.txt","chromosome_file_set_2.txt")
,c("annotation_file_set_1.txt","annotation_file_set_2.txt"),
ploidy = 2, data_based_color_map = T,data_type = "numeric"
,aggregate_func = c("avg","sum"))Note: If only one element is annotated per window, than the windows will take the element’s data value.
Please note that for construction of heatmaps, the domain (min-max)
used for colors is based on the min-max values of the data. You can
manually set the domain by using the numeric.domain
argument.It is a list of vectors where each vector specify the domain
for the ploidy.
e.g numeric.domain = list(c(0,100)) or for
diploid use numeric.domain =
list(c(0,100),c(-60,60)).
In addition to visualizing numeric data as heat colors on the
chromosomes, chromoMap allows creating data charts over the annotated
windows. chromoMap-Bar plot can be used to visualize
annotated data as barplots. You will need to use the plots
argument to specify the type of data charts you wish to visualize.
#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Visualizing..
The bars represents the aggregate_function values for
the windows. You can customize the chromoMap-Bar plots using various
properties described under customizing Data-Plots
section.
You can also turn off the heatmap feature to selectively visualize
the chromoMap-Bar plots ( applicable for all of the plots
discussed in the subsequent section). For that, set the
heat_map argument to FALSE.
chromoMap(chr_file_1,anno_file_1,
data_based_color_map = T,
data_type = "numeric",
plots = "bar",
heat_map = F)#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Visualizing..
chromoMap-Scatter plots allows to visualize each value
for a given annotated locus as scatter plot.
chromoMap(chr_file_1,anno_file_2,
data_based_color_map = T,
data_type = "numeric",
plots = "scatter")#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Visualizing..
chromoMap-Scatter plots are also interactive as the
tooltips for a scatter shows the annotated element name and value.
This feature allows to filter numeric data based on the various mathematical conditions.
Tag-filters allows you to selectively tag a locus based on
mathemetical condition on the data. If the condition is satisfied, the
locus will be tagged. tag-filters are passed using the
tag_filter argument. The argument is a list of vectors
where you can pass a vector for each ploidy. the vector specifies two
values necessary to pass for a filter. The first value specifies the
operation-type and the second value specifies the
operands. Following table describes all possible
operation-types along with usage example.
In general, filters are specified as
list(c("operation-type-label","operand1","operand2"))
| operation type label | description | usage example |
|---|---|---|
| eq | equal | list(c(“eq”,5)) |
| lt | less than | list(c(“lt”,-5)) |
| gt | greater than | list(c(“gt”,6)) |
| lte | less than equal | list(c(“lte”,6)) |
| gte | greater than equal | list(c(“gte”,6)) |
| gtalt | greater than AND less than | list(c(“gtalt”,5,-5)) |
| gtolt | greater than OR less than | list(c(“gtolt”,5,-5)) |
| gtealte | greater than equal AND less than equal | list(c(“gtealte”,5,-5)) |
| gteolte | greater than equal OR less than equal | list(c(“gteolte”,5,-5)) |
For instance, to tag the windows with negative number values:
chromoMap(chr_file_1,anno_file_2,
data_based_color_map = T,
data_type = "numeric",
plots = "tags",
tag_filter = list(c("lt",0)))#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Visualizing..
plot-filters are similar to tag-filters as they allow filtering of
numeric data based on mathematical conditions, but they are visualized
as condition-based coloring of chromoMap-Bar and
chromoMap-scatter plots. The plot_filter
argument allows you to pass filter conditions. It is also a list of
vector(s) similar to tag_filter above, except that you have
to pass an additional necessary option of color to it. If the condition
is satisfied, this color value is assigned.
So, plot-filters are specified as
list(c("operation-type-label","operand1","operand2","color-value"))
Here is an example of using plot-filter on chromoMap-Bar
plots. bars with value greater than and equal to are colored
‘green’.
chromoMap(chr_file_1,anno_file_1,
data_based_color_map = T,
data_type = "numeric",
plots = "bar",
plot_filter = list(c("gte",50,"green")))#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Visualizing..
Similarly, it can be applied for chromoMap-Scatter
plots. The following example visualizes negative values as red on the
scatter plot.
chromoMap(chr_file_1,anno_file_2,
data_based_color_map = T,
data_type = "numeric",
plots = "scatter",
plot_filter = list(c("lt",0,"red")))#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Visualizing..
In order to visualize a second factor onto the scatter plot, you can
now use a special plot_filter option. The input data
specifying the categories should be passed a secondary data column in
addition to the primary data.
the input data file now looks like:
head(anno_file_3)
#> V1 V2 V3 V4 V5 V6
#> 1 An1 chr1 558 560 10 C
#> 2 An2 chr2 396 398 34 B
#> 3 An3 chr2 281 283 89 B
#> 4 An4 chr1 125 127 56 A
#> 5 An5 chr2 406 408 100 B
#> 6 An6 chr2 340 342 91 DYou can specify the colors of each category by using the
ch2D.colors argument. The legend is automatically displayed
and can be adjusted with ch2D.lg_x and
ch2D.lg_y arguments.
chromoMap(chr_file_1,anno_file_3,
data_based_color_map = T,
data_type = "numeric",
plots = "scatter",
plot_filter = list(c("col","byCategory")),
ch2D.colors = c("pink3","orange3","purple","blue2"))#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Visualizing..
NOTE: As of now, only categorical data is supported as secondary data for this feature.
Users can now construct a new kind of plot called
2D-Chromosome plots. The plot basically visualize
annotations in 2D. The X-axis represent the chromosome split into
genomic windows, while the y-axis visualize the annotations within the
respective genomic windows with their positions relative to the start of
the genomic windows.
2D-Chr plots can be constructed by simply using the
chr.2D.plot argument which takes Boolean value.
#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Visualizing..
Not only that, you can visualize the feature-associated data as heat-maps.
You need to use the plot_filter argument to create the
heat-maps.
For numeric data, you need to pass a vector for
plot_filter specifying that you need to color by numeric
data: c("col","byNumber"). Please not as used previously,
plot_filter is a list which takes values per ploidy, that
means that you can construct 2D-chr plot in as multiple-ploidy or even
along with other types of plots like “scatter/bars”. You can use
plot_height to adjust the height of the plot.
#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Visualizing..
For numeric data, the legend can be adjusted using lg_x
or lg_y arguments just as you adjust he legends for
chromoMap-scatter/bar plots. Also, To change the colors use
data_colors argument.
You can also visualize categorical data as heatmap by using
c("col","byCategory") in plot_filter. I am
using the following data for anotation that has two groups “type1” and
“type2”.
head(read.table(anno_file_cate))
#> V1 V2 V3 V4 V5
#> 1 An1 chr1 558 560 type2
#> 2 An2 chr2 396 398 type2
#> 3 An3 chr2 281 283 type1
#> 4 An4 chr1 125 127 type2
#> 5 An5 chr2 406 408 type1
#> 6 An6 chr2 340 342 type2chromoMap(chr_file_1,anno_file_cate,
chr.2D.plot = T,
plot_filter = list(c("col","byCategory")),
ch2D.colors = c("red","blue"))#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 20
#> Visualizing..
For categorical data, you can use ch2D.lg_x or
ch2D.lg_y to adjust the legends. You can use
ch2D.colors to manually set the colors for each category.
Also ch2D.cat.order to manually set the order of
categories.
Also, although not recommended you can adjust height of annotation
bars in 2D-Chr plots by using ann.h argument.
chromLinks plots can be used to visualize links or
connections between any two features or windows. The two features can be
located on the same chromosome or on different chromosomes from the same
or different ploidies. The links data needs to be passed separately as a
data.frame where each row represents a connection between two features
and the columns represents:
The input data.frame should look like:
head(link_data)
#> V1 V2 V3 V4 V5
#> 1 An58 1 An194 1 100
#> 2 An98 1 An122 1 97
#> 3 An113 1 An132 1 95
#> 4 An119 1 An124 1 90
#> 5 An70 1 An120 1 80
#> 6 An105 1 An13 1 85NOTE: The ploidy columns in the data represents the ploidy of the genomic feature. Since, chromoMap allows using duplicate names in different ploidies, it is important to specify correct ploidy for a given feature.
chromoMap allows two ways to visualize the links between
two features:
chromoMap annotates the features by using either of the
two annotation algorithms, namely, point-annotation and
segment-annotation(discussed above). For the former type, links between
two annotated features are visualized as edges. To use the
links-visualization feature, you need to set the show.links
argument to TRUE and pass the links data.frame through the
loci_links argument.
chromoMap(chr_file, anno_file,
# main arguments
show.links = T,
loci_links = link_data[,c(1:4)],
links.colors = "red2",
#plot adjustments
ch_gap = 50,
y_chr_scale = 100,
top_margin = 100,
)#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 205
#> Visualizing..
The numeric or character data associated with the links can be color
coded. You just need to pass the data as fifth column. The legends are
automatically displayed. use links.lg_x and
links.lg_y arguments to adjust the legends.
chromoMap(chr_file, anno_file,
# main arguments
show.links = T,
loci_links = link_data,
links.colors = c("red2","blue2"),
#plot adjustments
ch_gap = 50,
y_chr_scale = 100,
top_margin = 100,
links.lg_y = 300
)#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 205
#> Visualizing..
and also categorical data:
chromoMap(chr_file, anno_file,
# main arguments
show.links = T,
loci_links = link_data,
links.colors = c("red2","blue2","orange3","purple"),
#plot adjustments
ch_gap = 50,
y_chr_scale = 100,
top_margin = 100,
)#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 205
#> Visualizing..
there is also an option to visualize the arrow-heads on the links to
signify direction. Use the directed.edges boolean
argument.
chromoMap(chr_file, anno_file,
# main arguments
show.links = T,
loci_links = link_data,
links.colors = c("red2","blue2","orange3","purple"),
directed.edges = T,
#plot adjustments
ch_gap = 50,
y_chr_scale = 100,
top_margin = 100,
)#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 205
#> Visualizing..
For segement-annotation plots, where features are usually large size
and are annotated as segments of the chromosomes, the links are
visualized as chords.
chromoMap(chr_file, anno_file,
# main arguments
segment_annotation = T,
show.links = T,
loci_links = link_data,
links.colors = c("orange3","purple","green2"),
#plot adjustments
ch_gap = 50,
y_chr_scale = 100,
top_margin = 100,
)#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 3
#> Processing data..
#> Number of annotations in data set 1 : 6
#> Visualizing..
Note: the colors can be passed using the links.colors
argument that takes a character vector specifying color(s) for the links
or data maps. For numeric data pass two colors and for categorical data
pass as many colors as there are categories.
chromoMap allows various options to customize and
fine-tune your plots as desirable. This section covers all the
customization options available.
You can configure the dimensions(width and height) of the plot by
using the parameter canvas_width and
canvas_height. From version 0.4.1 onwards, chromoMap
automatically adjust the width and height to fit the plot and provide
vertical and horizontal srolling in case of overflow.
When you use multiple ploidy, the plot might go off the margins. You can adjust the width and height to fit the plot to your need.
You can add a title to your plot by using title
argument.
You can also adjust the font-size of the title using the
title_font_size argument:
You can adjust the left and top margins through
top_margin and left_margin.
You can change the color of each set of chromosome by using
chr_color property.
For polyploidy, if only one color is passed it will be taken for all sets of chromsomes. Otherwise, you can assign color to each set:
chromoMap(c("chromosome_file_set_1.txt","chromosome_file_set_2.txt")
,c("annotation_file_set_1.txt","annotation_file_set_2.txt"),
ploidy = 2,
chr_color = c("pink","blue"))USEFUL TIPS :
For simple annotation plot, you can change the annotation color by
using anno_col argument.
For polyploidy, if you have passed one color value it will be taken for all the sets. Otherwise, you can pass distinct color values for each set:
chromoMap(c("chromosome_file_set_1.txt","chromosome_file_set_2.txt")
,c("annotation_file_set_1.txt","annotation_file_set_2.txt"),
ploidy = 2,
anno_col = c("pink","blue"))NOTE: For data-based annotation
plots(chromoMap-DiscreteColorMaps or
chromoMap-HeatMaps), colors are controlled by
data_colors argument which is passed as a list of
vector(s).
Do you think chromosomes appear too thin or too short for your
annotations? well, you can adjust these parameters by using
chr_width and chr_length arguments.
the spacing between chromosomes can be adjusted with
ch_gap argument.
The curves appearing at the telo-meres (chromosome end windows) and
in centromere locus can also be adjusted using the
chr_curve argument.
TIP: setting this property to 0 will remove the curves that render the chromosomes as rectangles.
You can adjust the y or vertical position of the chromosome scale
using the y_chr_scale argument.
Well, the chromosome text will be taken from file you have provided.
The only thing I thought might be useful is to enable or disable text
individually for each ploidy. This is done by using
chr_text parameter.
For multiple ploidy pass a vector:
chromoMap(c("chromosome_file_set_1.txt","chromosome_file_set_2.txt")
,c("annotation_file_set_1.txt","annotation_file_set_2.txt"),
ploidy = 2,
chr_text = c(T,F))you can adjust the text font size using text_font_size
parameter.
You can now disable/enable interactivity for chromosomes by using the
interactivity argument.
You can change the ‘suffix’ value used in the chromosome scale. By default it uses ‘bp’ but you can set to any other value or remove it by passing empty string ““.
You can set the number of ticks for chr scale using
chr.scale.ticks argument.
You can choose to show/hide the chromosomes for each ploidy by using
the display.chr argument. It can be different for different
ploidy like you can pass c(F,T) to this argument indicating
that you only want to hide the first ploidy chromosomes. NOTE that plots
will still be visible and you can adjust the plots with
plot_shift argument.
You can display guides in the background using the
guides argument. Guides will help separate each genomic
window. You can also set the color by guides_color.
The id argument allows to uniquely identify the plot.
This feature is important when including multiple chromoMap plots in a
single HTML document (like RMarkdown) as it prevent from any
conflicts.
As a test feature, chromoMap now automatically assigns
random color values if the colors are not passed manually. the color
values are randomly selected and change every time you plot. I would
still recommend using the manual color assignments.
Also, now you can use R color names such as ‘red3’ as color inputs.
chromoMap-Bar, chromoMap-Scatter , and
epi-tag plots can be customized as desired.
You can add a horizontal reference line to the data-plots. Set the
ref_line argument to TRUE. The reference line
is attached to the axis-scale. By default, the line is attached at the
beginning of the axis(position:0). You can adjust the
refl_pos argument to bring the line to desirable
position.
TIP:For the line to be at the middle of axis, set
refl_pos argument to exactly half of
plot_height.
chromoMap(chr_file_1,anno_file_1,
data_based_color_map = T,
data_type = "numeric",
plots = "bar",
ref_line = T,
refl_pos = 15)#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Visualizing..
Reference line in scatter plot:
chromoMap(chr_file_1,anno_file_2,
data_based_color_map = T,
data_type = "numeric",
plots = "scatter",
ref_line = T,
refl_pos = 20)#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Visualizing..
You can change the color and stroke-size of the reference line using
refl_color and refl_stroke_w arguments
respectively.
Change the plot height using plot_height parameter.
Change the plot colors (bar and scatter colors) using the
plot_color parameter.
chromoMap(chr_file_1,anno_file_2,
data_based_color_map = T,
data_type = "numeric",
plots = "scatter",
plot_color = "orange")For the epi-tag plots, you need to use tagColor argument
that will change the tag-head colors.
You can change the range of y-axis of the plots using
plot_y_domain argument. It is passed as list of vector(s),
a vector for each ploidy. You can also change the number of ticks of the
scale using the plot_ticks argument.
You can now set y-axis labels for the plots for each ploidy by using
plot.y.labels argument. Adjust the x nd y position of the
labels by using plot.y.lab.x and plot.y.lab.y
argument respectively. Set the size with
plot.y.lab.size.
vertical grid lines can be used to highlight specific regions of the
chromosomes. You can add any number of grid-lines to the plot. Set the
vertical_grid argument to TRUE. You can add
multiple grid lines by specifying a vector of positions(in bp) within
the max range of the plot(depicted by the horizontal chromosome scale).
The following example demonstrate the use of grid lines where 5 grid
lines are added at random genomic positions 1,54,100,420, and 621(the
entire scale is 1k bp wide). The plot also demonstrate the use of other
customization options.
chromoMap(c(chr_file_1,chr_file_1),c(anno_file_1,anno_file_2),
ploidy = 2
data_based_color_map = T,
data_type = "numeric",
plots = c("bar","scatter"),
plot_height = 40,
plot_color = c("green","red"),
ref_line = T,
refl_pos = 20,
#gridline arguments
vertical_grid = T,
grid_array = c(1,54,100,420,621))#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 2
#> Number of Chromosomes in set 1 : 2
#> Number of Chromosomes in set 2 : 2
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Number of annotations in data set 2 : 200
#> Visualizing..
You can also add text/labels for individual grid line. the text will
added at the top end of the grid-line and needs to be passed as an
array(vector) of texts for each corresponding position passed in
grid_array. Use the grid_text argument to pass
the text, grid_text_size to specify the text font-size,
grid_text_y to adjust the vertical position of the texts,
and grid_color to change color of grid-lines.
chromoMap(c(chr_file_1,chr_file_1),c(anno_file_1,anno_file_2),
ploidy = 2
data_based_color_map = T,
data_type = "numeric",
plots = c("bar","scatter"),
plot_height = 40,
plot_color = c("green","red"),
ref_line = T,
refl_pos = 20,
#gridline arguments
vertical_grid = T,
grid_array = c(1,54,100,420,621),
grid_text = c("","","mark 1","region 1",""))#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 2
#> Number of Chromosomes in set 1 : 2
#> Number of Chromosomes in set 2 : 2
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Number of annotations in data set 2 : 200
#> Visualizing..
Note: for the grid-lines for which no text was displayed an empty
string "" is added corresponding to the grid-line position.
The length of grid_array and grid_text should
match.
chromoMap now supports a quick zoom-in feature that
allow the users to zoom in on a specific region of interest on any
chromosome. The region information is passed with the
region argument which is a character vector containing
region(s) in the following format:
c("<chromsome name>:<ploidy>:<region start>:<region stop>")
eg. c(“chr1:1:5142689:6478512”)
chromoMap(chr_file_1,anno_file_2,
data_based_color_map = T,
data_type = "numeric",
plots = "scatter",
#highlighting a region on chr1
vertical_grid = T,
grid_array = c(550,754))#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 200
#> Visualizing..
chromoMap(chr_file_1,anno_file_2,
data_based_color_map = T,
data_type = "numeric",
plots = "scatter",
#zoom in
region = c("chr1:1:550:754"))#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> WARNING: 80 out-of-bound annotations are removed in chromosome set 1 .
#> Number of annotations in data set 1 : 120
#> Visualizing..
Note: the scale of the chromosomes will be updated based on their new length. The region zoom could have been done by modifying the chromosome range in the input chromosome files but this argument provides a quick option to view a region of interest without changing the master chromosome data.
multiple regions can also be passed as:
chromoMap(chr_file_1,anno_file_2,
data_based_color_map = T,
data_type = "numeric",
plots = "scatter",
#zoom in
region = c("chr1:1:550:754","chr2:1:221:450"))#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> WARNING: 138 out-of-bound annotations are removed in chromosome set 1 .
#> Number of annotations in data set 1 : 62
#> Visualizing..
legends are provided for data-based annotation plots
(chromoMap-DiscreteColorMaps and
chromoMap-HeatMaps). It is hidden by default. Use
legend option to enable it.
chromoMap("chromosome_file.txt","annotation_file.txt",
data_based_color_map = T,
data_type = "categorical",
legend = T) For polyploidy, you can enable or disable the legend independently for each set.
chromoMap(c("chromosome_file_set_1.txt","chromosome_file_set_2.txt")
,c("annotation_file_set_1.txt","annotation_file_set_2.txt"),
ploidy = 2,
data_based_color_map = T,
data_type = "numeric",
legend = c(F,T))I know, the legends in your plot are present weirdly?. I have made
the postion of legends independent of the plot and hence you can
position it anywhere in the plot you want using the y and x direction
length. Consider the orgin to be the bottom right corner of the plot now
tweak the lg_x and/or lg_y arguments to adjust
the positioning of the legend.
For numeric-data plots like scatter/bar use
plot.legend.labels for each ploidy. For categorical data
legends, use cat.legend.label. Note that for categorical
data plots, only one legend is shown with all categories.
This feature I added at the end thought might be useful in some
scenarios. This will show the labels (element names) on top of locus. It
is disabled by default, to enable it use label
argument.
#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 20
#> Visualizing..
You can change the labels angle and font-size using
label_angle and label_font arguments
respectively.
chromoMap("chromosome_file.txt","annotation_file.txt",
labels=T,
label_font = 12,
label_angle = -65)#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 20
#> Visualizing..
TIP: To make the labels non-overlapping, tweak the chromosome length and width properties like shown in the following example.
chromoMap("chromosome_file.txt","annotation_file.txt",
labels=T,
label_angle = -65,
chr_length = 6,
chr_width = 25,
canvas_width = 800)#> ********************************** __ __ ************
#> ** __**|__ * __* __ * __ __ * __ *| | |* __ * __ **
#> **|__**| |*| *|__|*| | |*|__|*| | |*|_ |*|__|**
#> ***********************************************| **
#> *****************************************************
#> OUTPUT:
#> Number of Chromosome sets: 1
#> Number of Chromosomes in set 1 : 2
#> Processing data..
#> Number of annotations in data set 1 : 20
#> Visualizing..
This feature will allow you to add hyperlinks with elements. Add
hyperlinks in annotations file and don’t forget to use
hlinks argument to enable it.
The RStudio allows the option to export the graphics,
shown in its viewer’s pane ,as either a static image or a web page. Use
this feature to either save chromoMaps as static images and include them
into your documents or papers, or export interactive plots as
standalone-html to include them as supplementary materials in
publications.
From version 0.4.1, chromoMap has an in-built exporting options that
provide buttons to export the plot as either PNG or SVG. In order to use
it, set the export.options argument to TRUE.
You will see export buttons at the bottom of plot.
IMPORTANT The buttons might not work in RStudios’ viewer pane. you can first export the plot as “WEB Page/HTML” and then view it in a broweser like Chrome.
You can include chromoMaps in Shiny application by using the function
chromoMapOutput() in the UI part of the code and
renderChromoMap() in the server part of the code.
library(shiny)
library(chromoMap)
# Define UI for application that draws chromoMap
ui <- fluidPage(
# Application title
titlePanel("An example of chromoMap in Shiny"),
# you can use GUI controls for your chromoMap
sidebarLayout(
sidebarPanel(
#some code
),
# Show a plot of the generated distribution
mainPanel(
chromoMapOutput("myChromoMap")
)
)
)
# Define server logic required to draw chromoMap
server <- function(input, output) {
output$myChromoMap <- renderChromoMap({
chromoMap("chromosome_file.txt","annotation_file.txt")
})
}
# Run the application
shinyApp(ui = ui, server = server)The chromoMap package is distributed under GPL-3 (GNU GENERAL PUBLIC LICENSE version 3).
You are welcome to send feedback or bug reports through e-mail [email protected]
chromoMap is now published in BMC Bioinformatics
journal. Please visit the site for citing options.
sessionInfo()
#> R version 4.6.1 (2026-06-24)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 26.04.1 LTS
#>
#> Matrix products: default
#> BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so; LAPACK version 3.12.0
#>
#> locale:
#> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
#> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
#> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
#> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
#>
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] knitr_1.52 chromoMap_4.1.1
#>
#> loaded via a namespace (and not attached):
#> [1] digest_0.6.39 R6_2.6.1 fastmap_1.2.0 xfun_0.61
#> [5] maketools_1.3.2 cachem_1.1.0 htmltools_0.5.9 rmarkdown_2.32
#> [9] buildtools_1.0.0 lifecycle_1.0.5 cli_3.6.6 sass_0.4.10
#> [13] jquerylib_0.1.4 compiler_4.6.1 sys_3.4.3 tools_4.6.1
#> [17] evaluate_1.0.5 bslib_0.12.0 yaml_2.3.12 htmlwidgets_1.6.4
#> [21] jsonlite_2.0.0 rlang_1.3.0chromoMap