---
title: "chromoMap v0.4.1 Documentation (R package)"
output:
  html_document:
    self_contained: yes
    toc: yes
    toc_float: true
vignette: |
  %\VignetteIndexEntry{chromoMap-An R package for Interactive Genomic Visualization of Multi-Omics Data} 
  %\VignetteEngine{knitr::rmarkdown} 
  %\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
#knitr::opts_chunk$set(widgetframe_widgetsdir = 'widgets')
```

<style>
    
       
h2,h3 {color: #10B85F;}
    
.list-group-item.active, .list-group-item.active:focus, .list-group-item.active:hover {
    background-color: #10B85F;
}
.active {
  background-color: #353436;
  background-image: linear-gradient(to right, #353436 , #78AF9F);
}


</style>




<p><strong>NOTE</strong>: This Documentation is also available as R Vignette.</p>

`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:

- visualizing polyploidy simultaneously on the same plot.
- Create high-resolution maps.
- annotating groups of elements as distinct colors using `chromoMap-DiscreteColorMaps`.
- visualizing multi-omics data associated with features using a variety of plots like `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).
- Create `2-Dimensional Chromosome` plots.
- Visualize correlations between genomic features using the `chromLinks plots`
- adjusting chromosome range or visualizing chromosome regions such as genes
- adding labels to the plot
- adding hyperlinks to each element


## Getting Started

This 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.  


### Install `chromoMap`

You can install the package by just typing the following commands:
```{r, eval=FALSE}
install.packages("chromoMap")

```

### Prepare Input Data Files
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)

#### Chromosome Files

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):

- **chromosome name**: a character representing the chromosome/contig/region name like 'chr1' or '1' or 'ch1'
- **chromosome start**: a numeric value to specify chromosome (or chromosome region) start position. If you are considering entire chromosome this value is typically 1.
- **chromsome end**: a numeric value specifying chromosome/contig/region end position. Again, if you are considering entire chromosome, then this value is the length of chromosome.
- **centromere start (optional)**: centromeres will be added automatically if you provide the its start cordinates. 

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:
<center>
![](images/f1.PNG)


</center>

#### Annotation Files

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.

- **Element Name**: a character specifying (uniquely) the elements. This can be identifiers,symbols etc.
- **Chromosome Name**: a character specifying the chromosome name. [NOTE: the chromosome names should be consistent in chromosome and data files.]
- **Element Start**: A numeric specifying element start position.
- **Element End**: A numeric specifying element end position.
- **Data(optional)**:  A numeric or character specifying the data value.
- **Secondary Data(optional)**:  A vector specifying the data value.useful for multi-factor scatter plots.
- **Hyperlinks(optional)**: a character specifying the URL of the element. 

your annotation file should look like:

<center>

![](images/f2.PNG)


</center>


<br><br>

To prevent you from making some possible errors, here are a few points to care about while preparing files:

- Do not include column headers in files.
- Chromosomes names should be consistent in both files.
- Elements and chromosome names (first column of both files) should be unique.


**TIP**: You can use MS excel to create your files and then use save as tab-delimited option.



#### chromoMap files for this vignette

For the plots in this vignette, I will be using synthetic chromosome and annotation files. 

```{r}
# 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:

```{r,echo=F}

library(chromoMap)
#my_path <- "C:/Users/laksh/Documents/PROJECTS/chromoMap_v3_production/chromoMap/vignettes/data/"
my_path = "data/"

chr_file_1 <- paste0(my_path,chr_file_1)
chr_file_2 <- paste0(my_path,chr_file_2)
anno_file_1 <-paste0(my_path,anno_file_1)
anno_file_2 <-paste0(my_path,anno_file_2)
anno_file_cate <- paste0(my_path,"discrete_colormap.txt")


```

chromosome file:

```{r}

head(read.table(chr_file_1,sep = "\t"))
```

Chromosome file with centromere:

```{r}

head(read.table(chr_file_2,sep = "\t"))
```

Annotation file with positive data.

```{r}

head(read.table(anno_file_1,sep = "\t"))
```

Annotation file with both positive and negative data.

```{r}

head(read.table(anno_file_2,sep = "\t"))
```


### R objects as chromoMap Inputs

`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. 

```{r eval=F}
# 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).

## My first `chromoMap`

Once you have your input files ready, begin creating chromosomes plots like a pro. The simple annotation plot can be created using the following command:


```{r, eval=F}
library(chromoMap)
chromoMap(chr_file_1,anno_file_1)

```

```{r, echo=F, fig.height=2}
chromoMap(chr_file_1,anno_file_1,canvas_height = 200,id="cmap1")

```

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:

- the range of the selected locus in bp
- the count showing total elements mapped at this locus
- the element(s) names mapped at this locus which is clickable

<center>

![](images/p2.PNG)

</center>

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.

```{r, eval=F}
library(chromoMap)
chromoMap(chr_file_2,anno_file_1)

```

```{r, echo=F, fig.height=2}
chromoMap(chr_file_2,anno_file_1,canvas_height = 200,id="cmap189564")

```

## Polyploidy
 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.
 
```{r, eval=F}
library(chromoMap)
chromoMap(c(chr_file_1,chr_file_1),c(anno_file_1,anno_file_2),
          ploidy = 2)

```

```{r, echo=F, fig.height=2}
chromoMap(c(chr_file_1,chr_file_1),c(anno_file_1,anno_file_2),
          ploidy = 2,canvas_height = 300,id="cmap2")

```



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.


## Point and Segment-annotation plots

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. 

```{r,eval=F}
chromoMap("chromosome_file.txt","annotation_file.txt",segment_annotation = T)

```


here's a hypothetical example(exon regions of the genes g1,g2 and g3).

<center>

![](images/P4.jpeg)

</center>

## High-Resolution Maps

`chromoMap` now supports construction of high resolution maps using by either scaling the number of windows per chromosome or by choosing arbitrary window size.

### Window Scaling

`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.


```{r, eval=F}
# default value
library(chromoMap)
chromoMap(chr_file_1,anno_file_1,
          n_win.factor = 1,
          win.summary.display=T)

```

```{r, echo=F, fig.height=2}
chromoMap(chr_file_1,anno_file_1,canvas_height = 200,
          id="cmapRR1",n_win.factor = 1,
          win.summary.display=T)

```

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).

<br>

Now, increasing the #windows 3 times #windows for the longest chromsome.

```{r, eval=F}
library(chromoMap)
chromoMap(chr_file_1,anno_file_1,
          n_win.factor = 3,
          win.summary.display = T)

```

```{r, echo=F, fig.height=2,fig.width=1}
chromoMap(chr_file_1,anno_file_1,canvas_height = 200,id="cmapRR2",
          n_win.factor = 3,win.summary.display = T)

```

### Fixed-Window

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`.


```{r, eval=F}
library(chromoMap)
chromoMap(chr_file_1,anno_file_1,
          fixed.window = T,
          window.size = 5,
          win.summary.display = T)

```

```{r, echo=F, fig.height=2,fig.width=1}
chromoMap(chr_file_1,anno_file_1,canvas_height = 200,id="cmapRRu2",
          fixed.window = T,window.size = 5,win.summary.display = T)

```

**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.


## Data-based annotation plots

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`.


### chromoMap-DiscreteColorMaps

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.

```{r,eval=F}
chromoMap("chromosome_file.txt","annotation_file.txt",
          data_based_color_map = T,
          data_type = "categorical",
          data_colors = list(c("orange","yellow")))

```

```{r, echo=F, fig.height=3}
chromoMap(chr_file_1,"data/discrete_colormap.txt",data_based_color_map = T,data_type = "categorical",legend = T,canvas_height = 250,id="cmap310",data_colors = list(c("orange","yellow")),
          lg_x = 15)

```

#### Manually setting the order of categories

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

`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.

```{r,eval=FALSE}
chromoMap(chr_file_1,anno_file_2,
          data_based_color_map = T,
          data_type = "numeric")
```


```{r, echo=F, fig.height=3.5}
chromoMap(chr_file_1,anno_file_2,data_based_color_map = T,data_type = "numeric",legend = T,canvas_height = 300,id="cmap4",lg_y = 50)

```


`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.

#### Data Aggregation

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:

```{r,eval=FALSE}
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:

```{r,eval=FALSE}
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.

#### Manually changing the data domain for heatmap
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))`.


### chromoMap-Bar Plots

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.

```{r,eval=FALSE}
chromoMap(chr_file_1,anno_file_1,
          data_based_color_map = T,
          data_type = "numeric",
          plots = "bar")
```


```{r, echo=F, fig.height=3.5}
chromoMap(chr_file_1,anno_file_1,data_based_color_map = T,data_type = "numeric",canvas_height = 300,id="cmap5",lg_y = 50,
          plots = "bar",plot_ticks = 3)

```


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`.

```{r,eval=FALSE}
chromoMap(chr_file_1,anno_file_1,
          data_based_color_map = T,
          data_type = "numeric",
          plots = "bar",
          heat_map = F)
```


```{r, echo=F, fig.height=3.5}
chromoMap(chr_file_1,anno_file_1,data_based_color_map = T,data_type = "numeric",canvas_height = 300,id="cmap51",lg_y = 50,
          plots = "bar",heat_map = F,plot_ticks = 3)

```


### chromoMap-Scatter Plots

`chromoMap-Scatter` plots allows to visualize each value for a given annotated locus as scatter plot. 

```{r,eval=FALSE}
chromoMap(chr_file_1,anno_file_2,
          data_based_color_map = T,
          data_type = "numeric",
          plots = "scatter")
```


```{r, echo=F, fig.height=3.5}
chromoMap(chr_file_1,anno_file_2,data_based_color_map = T,data_type = "numeric",canvas_height = 300,id="cmap6",lg_y = 50,
          plots = "scatter",left_margin = 60,plot_height = 40)

```

`chromoMap-Scatter` plots are also interactive as the tooltips for a scatter shows the annotated element name and value.


### epi-tags

`epi-tags` are special plots that allow to add `tags` over annotated windows. 

```{r,eval=FALSE}
chromoMap(chr_file_1,anno_file_2,
          data_based_color_map = T,
          data_type = "numeric",
          plots = "tags")
```


```{r, echo=F, fig.height=3.5}
chromoMap(chr_file_1,anno_file_2,data_based_color_map = T,data_type = "numeric",canvas_height = 300,id="cmap7",
          plots = "tags")

```


These `epi-tags` can be filtered based on mathematical conditions on the data (discussed in the next section.)


## chromoMap-Filters

This feature allows to filter numeric data based on the various mathematical conditions. 

### tag-filters

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"))`

```{r,echo=F}
library(knitr)
OPERATION_TYPE_LABEL = c("eq","lt","gt","lte","gte","gtalt","gtolt","gtealte","gteolte")
DESCRIPTION = c("equal","less than","greater than","less than equal","greater than equal","greater than AND less than","greater than OR less than","greater than equal AND less than equal","greater than equal OR less than equal")
USAGE_EXAMPLE = c('list(c("eq",5))','list(c("lt",-5))','list(c("gt",6))','list(c("lte",6))','list(c("gte",6))','list(c("gtalt",5,-5))','list(c("gtolt",5,-5))','list(c("gtealte",5,-5))','list(c("gteolte",5,-5))')
gggg = data.frame(OPERATION_TYPE_LABEL,DESCRIPTION,USAGE_EXAMPLE)
colnames(gggg)=c("operation type label","description","usage example")
kable(gggg)

```


For instance, to tag the windows with negative number values:


```{r,eval=FALSE}
chromoMap(chr_file_1,anno_file_2,
          data_based_color_map = T,
          data_type = "numeric",
          plots = "tags",
          tag_filter = list(c("lt",0)))
```


```{r, echo=F, fig.height=3.5}
chromoMap(chr_file_1,anno_file_2,data_based_color_map = T,data_type = "numeric",canvas_height = 300,id="cmap8",
          plots = "tags",tag_filter = list(c("lt",0)))

```





### plot-filters

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'.

```{r,eval=FALSE}
chromoMap(chr_file_1,anno_file_1,
          data_based_color_map = T,
          data_type = "numeric",
          plots = "bar",
          plot_filter = list(c("gte",50,"green")))
```


```{r, echo=F, fig.height=3.5}
chromoMap(chr_file_1,anno_file_1,data_based_color_map = T,data_type = "numeric",canvas_height = 300,id="cmap9",
          plots = "bar",plot_filter = list(c("gte",50,"green")),plot_ticks = 3)

```


Similarly, it can be applied for `chromoMap-Scatter` plots. The following example visualizes negative values as red on the scatter plot.


```{r,eval=FALSE}
chromoMap(chr_file_1,anno_file_2,
          data_based_color_map = T,
          data_type = "numeric",
          plots = "scatter",
          plot_filter = list(c("lt",0,"red")))
```


```{r, echo=F, fig.height=3.5}
chromoMap(chr_file_1,anno_file_2,data_based_color_map = T,data_type = "numeric",canvas_height = 300,id="cmap10",lg_y = 50,
          plots = "scatter",left_margin = 60,plot_filter = list(c("lt",0,"red")),plot_height = 40)

```

### multi-factor scatter plots

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. 

```{r echo=F}
  anno_file_3 <- read.table("data/ANNO_DATA_FOR_CATSCATTER.txt")
```

the input data file now looks like:

```{r}
head(anno_file_3)
```

You 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.

```{r,eval=FALSE}
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"))
```


```{r, echo=F, fig.height=3.5}
chromoMap(chr_file_1,"data/ANNO_DATA_FOR_CATSCATTER.txt",data_based_color_map = T,data_type = "numeric",canvas_height = 300,id="cmapnew10",lg_y = 50,
          plots = "scatter",left_margin = 60,plot_filter = list(c("col","byCategory")),plot_height = 40,
          ch2D.colors = c("pink3","orange3","purple","blue2"),canvas_width = 600,
          ch2D.lg_y = 100)

```

NOTE: As of now, only categorical data is supported as secondary data for this feature.


<br><br>

## 2D-Chromosome Plots
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.

```{r,eval=FALSE}
chromoMap(chr_file_1,anno_file_2,
          chr.2D.plot = T)
```


```{r, echo=F, fig.height=3.5}
chromoMap(chr_file_1,anno_file_2,chr.2D.plot = T,canvas_height = 300,id="cmaphyd10")

```

Not only that, you can visualize the feature-associated data as heat-maps.

### 2D-Chr Heatmaps

You need to use the `plot_filter` argument to create the heat-maps.

#### for Numeric Data

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.


```{r,eval=FALSE}
chromoMap(chr_file_1,anno_file_2,
          chr.2D.plot = T,
          plot_filter = list(c("col","byNumber")))
```


```{r, echo=F, fig.height=3.5}
chromoMap(chr_file_1,anno_file_2,chr.2D.plot = T,canvas_height = 300,id="cmaphiygd10",plot_filter = list(c("col","byNumber")),
          lg_x = 10)

```

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.

#### for Categorical Data

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".

```{r}
head(read.table(anno_file_cate))
```

```{r,eval=FALSE}
chromoMap(chr_file_1,anno_file_cate,
          chr.2D.plot = T,
          plot_filter = list(c("col","byCategory")),
          ch2D.colors = c("red","blue"))
```


```{r, echo=F, fig.height=3.5}
chromoMap(chr_file_1,anno_file_cate,chr.2D.plot = T,canvas_height = 300,id="cmtrphiygd10",plot_filter = list(c("col","byCategory")),
                                                                                  ch2D.colors = c("red","blue"),ch2D.lg_x = 15
          )

```

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

`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:

- column 1: name of the first feature (as used in annotation data) [type: character]
- column 2: ploidy of the first feature. [type: numeric]
- column 3: name of the second feature [ type: character]
- column 4: ploidy of the second feature. [type: numeric]
- column 5(optional): associated data for the link [type: numeric or character]

```{r echo=F}
chr_file <- "data/SLINK_chr.txt"
anno_file <- "data/SLINK_anno.txt"
link_data <- read.csv("data/SLINK22.csv",header = T)
```

The input data.frame should look like:

```{r}
head(link_data)
```


NOTE: 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:

### Visualizing links as Edges

`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. 

```{r eval=F}
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,
          )
```

```{r echo=F,fig.height=4.0}
chromoMap(chr_file, anno_file,
          show.links = T,
          loci_links = link_data[,c(1:4)],
          #plot adjustments
          links.colors = "red2",
          ch_gap = 50,
          y_chr_scale = 100,
          top_margin = 100,
          id="cnew1"
          )
```


#### color mapping links data

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.

```{r eval=F}
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
          )
```

```{r echo=F,fig.height=4.0}
chromoMap(chr_file, anno_file,
          show.links = T,
          loci_links = link_data,
          #plot adjustments
          links.colors =  c("red2","blue2"),
          ch_gap = 50,
          y_chr_scale = 100,
          top_margin = 100,
          id="cnew2",
          canvas_width = 600,
          links.lg_y = 30
          )
```



and also categorical data:

```{r echo=F}
link_data <- read.csv("data/SLINK_link2.csv",header = F)
```

```{r eval=F}
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,
          )
```

```{r echo=F,fig.height=4.0}
chromoMap(chr_file, anno_file,
          show.links = T,
          loci_links = link_data,
          #plot adjustments
          links.colors =  c("red2","blue2","orange3","purple"),
          ch_gap = 50,
          y_chr_scale = 100,
          top_margin = 100,
          id="cnew3",
          canvas_width = 600,
          links.lg_y = 30
          )
```

#### directed edges

there is also an option to visualize the arrow-heads on the links to signify direction. Use the `directed.edges` boolean argument.

```{r eval=F}
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,
          )
```

```{r echo=F,fig.height=4.0}
chromoMap(chr_file, anno_file,
          show.links = T,
          loci_links = link_data,
          #plot adjustments
          links.colors =  c("red2","blue2","orange3","purple"),
          ch_gap = 50,
          y_chr_scale = 100,
          top_margin = 100,
          id="cnew33",
          canvas_width = 600,
          links.lg_y = 30,
          directed.edges = T
          )
```


### Visualizing links as Chords

For segement-annotation plots, where features are  usually large size and are annotated as segments of the chromosomes, the links are visualized as `chords`.

```{r echo=F}
chr_file <- "data/TEST_chr.txt"
anno_file <- "data/TEST_anno.txt"
link_data <- read.csv("data/TEST_LINKSSS.csv",header = T)
```

```{r eval=F}
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,
          )
```

```{r echo=F,fig.height=4.0}
chromoMap(chr_file, anno_file,
          show.links = T,
          loci_links = link_data,
          segment_annotation = T,
          #plot adjustments
          links.colors =  c("orange3","purple","green2"),
          ch_gap = 50,
          y_chr_scale = 100,
          top_margin = 100,
          id="cnew4",
          canvas_width = 600,
          links.lg_y = 30
          )
```



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.

<br>
<br>



## Customizing chromoMaps

`chromoMap` allows various options to customize and fine-tune your plots as desirable. This section covers all the customization options available.


### width and height

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.

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          canvas_width = 600,
          canvas_height = 700)
```

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. 

### Title

You can add a title to your plot by using `title` argument.

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          title = "my first chromoMap plot")
```

You can also adjust the font-size of the title using the `title_font_size` argument:

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          title = "my first chromoMap plot",
          title_font_size = 12)
```

### Margins

You can adjust the left and top margins through `top_margin` and `left_margin`.

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          top_margin = 25,
          left_margin = 15)
```




### Chromosome colors 
You can change the color of each set of chromosome by using `chr_color` property.

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          chr_color = c("orange"))
```

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:

```{r,eval=FALSE}
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** : 

- Use hexadecimal color codes to assign beautiful color shades to embellish your plot. 
- setting the chromosome color to white will make them appear invisible hence only colored annotations will be visible(might be helpful in some case).


### Annotation colors
For simple annotation plot, you can change the annotation color by using `anno_col` argument. 

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          anno_col = c("orange"))
```

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:

```{r,eval=FALSE}
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).

### Chromosome width, length, and spacing

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.

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          chr_width = 4,
          chr_length = 5)
```


the spacing between chromosomes can be adjusted with `ch_gap` argument.

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          ch_gap = 6)
```

### Chromosome curves

The curves appearing at the telo-meres (chromosome end windows) and in centromere locus can also be adjusted using the `chr_curve` argument.

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          chr_curve = 5)
```


**TIP**: setting this property to 0 will remove the curves that render the chromosomes as rectangles.

### Chromsome scale y-position

You can adjust the y or vertical position of the chromosome scale using the `y_chr_scale` argument.


### Chromosome text
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.
```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          chr_text = F) 
```

For multiple ploidy pass a vector:
```{r eval=FALSE}
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.

### Interactivity

You can now disable/enable interactivity for chromosomes by using the `interactivity` argument.

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          interactivity = F)
```

### Chr Scale Suffix

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 "".

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          scale.suffix = "cM")
```
### Chr Scale Ticks

You can set the number of ticks for chr scale using `chr.scale.ticks` argument.

### Show/hide Chromosomes
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.

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          display.chr = c(F))
```

### Guides

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`.

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          guides = T,
          guides_color = "black")
```

### plot ID

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.

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          id="my_plot_1") 
```

### Automatic color assignments

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.


## Customizing Data Plots

`chromoMap-Bar`, `chromoMap-Scatter` , and `epi-tag` plots can be customized as desired. 

### Reference Lines

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`. 

```{r,eval=FALSE}
chromoMap(chr_file_1,anno_file_1,
          data_based_color_map = T,
          data_type = "numeric",
          plots = "bar",
          ref_line = T,
          refl_pos = 15)
```


```{r, echo=F, fig.height=3.5}
chromoMap(chr_file_1,anno_file_1,data_based_color_map = T,data_type = "numeric",canvas_height = 300,id="cmap21",
          plots = "bar",plot_ticks = 3,ref_line = T,
          refl_pos = 15)

```


Reference line in scatter plot:


```{r,eval=FALSE}
chromoMap(chr_file_1,anno_file_2,
          data_based_color_map = T,
          data_type = "numeric",
          plots = "scatter",
          ref_line = T,
          refl_pos = 20)
```


```{r, echo=F, fig.height=3.5}
chromoMap(chr_file_1,anno_file_2,data_based_color_map = T,data_type = "numeric",canvas_height = 300,id="cmap22",lg_y = 50,
          plots = "scatter",left_margin = 60,plot_height = 40,ref_line = T,refl_pos = 20)

```


You can change the color and stroke-size of the reference line using `refl_color` and `refl_stroke_w` arguments respectively.



### Plot height

Change the plot height using `plot_height` parameter.

```{r,eval=FALSE}
chromoMap(chr_file_1,anno_file_2,
          data_based_color_map = T,
          data_type = "numeric",
          plots = "scatter",
          plot_height = 50)
```

### Plot Colors

Change the plot colors (bar and scatter colors) using the `plot_color` parameter.

```{r,eval=FALSE}
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.

```{r,eval=FALSE}
chromoMap(chr_file_1,anno_file_2,
          data_based_color_map = T,
          data_type = "numeric",
          plots = "tags",
          tagColor = "orange")
```

### Plot y-axis range and ticks

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.

```{r,eval=FALSE}
chromoMap(chr_file_1,anno_file_2,
          data_based_color_map = T,
          data_type = "numeric",
          plots = "scatter",
          plot_ticks = 3,
          plot_y_domain = list(c(-5,5)))
```

### Plot y Labels
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`.

## Highlighting with grid lines


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.


```{r,eval=FALSE}
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))
```


```{r, echo=F, fig.height=3.5}
chromoMap(c(chr_file_1,chr_file_1),c(anno_file_1,anno_file_2),data_based_color_map = T,data_type = "numeric",canvas_height = 400,id="cmap23",ploidy = 2,
          plots = c("bar","scatter"),
          plot_height = 40,
          plot_color = c("green","red"),
          ref_line = T,
          refl_pos = 20,
          vertical_grid = T,
          grid_array = c(1,54,100,420,621),left_margin = 60)

```


#### adding labels to grid lines

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.


```{r,eval=FALSE}
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",""))
```


```{r, echo=F, fig.height=3.5}
chromoMap(c(chr_file_1,chr_file_1),c(anno_file_1,anno_file_2),data_based_color_map = T,data_type = "numeric",canvas_height = 400,id="cnew4125",ploidy = 2,
          plots = c("bar","scatter"),
          plot_height = 40,
          plot_color = c("green","red"),
          ref_line = T,
          refl_pos = 20,
          vertical_grid = T,
          grid_array = c(1,54,100,420,621),left_margin = 60
          ,grid_text = c("","","mark 1","region 1",""))

```


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.

## Quick Zoom-in 

`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") 

#### highlighting a region

```{r,eval=FALSE}
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))
```


```{r, echo=F, fig.height=3.5}
chromoMap(chr_file_1,anno_file_2,data_based_color_map = T,data_type = "numeric",canvas_height = 300,id="new7777",lg_y = 50,
          plots = "scatter",left_margin = 60,plot_height = 40,
          vertical_grid = T,
          grid_array = c(550,754))

```

#### zooming in on that region

```{r,eval=FALSE}
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"))
```


```{r, echo=F, fig.height=3.5}
chromoMap(chr_file_1,anno_file_2,data_based_color_map = T,data_type = "numeric",canvas_height = 300,id="new77894",lg_y = 50,
          plots = "scatter",left_margin = 60,plot_height = 40,
           region = c("chr1:1:550:754"))

```

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:

```{r,eval=FALSE}
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"))
```


```{r, echo=F, fig.height=3.5}
chromoMap(chr_file_1,anno_file_2,data_based_color_map = T,data_type = "numeric",canvas_height = 300,id="newh745994",lg_y = 50,
          plots = "scatter",left_margin = 60,plot_height = 40,
           region = c("chr1:1:550:754","chr2:1:221:450"))

```


## Legends

legends are provided for data-based annotation plots (`chromoMap-DiscreteColorMaps` and `chromoMap-HeatMaps`). It is hidden by default. Use `legend` option to enable it.

```{r,eval=FALSE}
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.

```{r eval=FALSE}
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))
```


### positioning legends

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.

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          data_based_color_map = T,
          data_type = "categorical",
          legend = T, lg_x = 100,
          lg_y = 250)
```

### Legend labels

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.


## Labellings

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.

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          labels=T)
```


```{r, echo=F, fig.height=3}
chromoMap(chr_file_1,"data/discrete_colormap.txt",
          canvas_height = 250,id="cmap1254",labels = T)

```


You can change the labels angle and font-size using `label_angle` and `label_font` arguments respectively.

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          labels=T,
          label_font = 12,
          label_angle = -65)
```


```{r, echo=F, fig.height=3}
chromoMap(chr_file_1,"data/discrete_colormap.txt",
          canvas_height = 250,id="cmap1925",labels = T,
          label_font = 10,
          label_angle = -65)

```

**TIP**: To make the labels non-overlapping, tweak the chromosome length and width properties like shown in the following example.

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          labels=T,
          label_angle = -65,
          chr_length = 6,
          chr_width = 25,
          canvas_width = 800)
```


```{r, echo=F, fig.height=3}
chromoMap(chr_file_1,"data/discrete_colormap.txt",
          canvas_height = 250,id="cmap17445",labels = T,
          chr_length = 7,
          chr_width = 25,
          canvas_width = 900,label_font = 10,label_angle = -65)

```


## Hyperlinks

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.

```{r,eval=FALSE}
chromoMap("chromosome_file.txt","annotation_file.txt",
          hlinks=T)
```

## Export to PNG/SVG/HTML 

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.

### In-built Export Options

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.



## Including chromoMaps in Shiny Applications

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.

#### Shiny Application example

```{r,eval=FALSE}
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)

```


## license
The chromoMap package is distributed under GPL-3 (GNU GENERAL PUBLIC
LICENSE version 3).

## Contact 
You are welcome to send feedback or bug reports through e-mail lakshayanan15@gmail.com

## Cite
`chromoMap` is now published in BMC Bioinformatics journal. Please visit the site for citing options.

[link to publication](https://bmcbioinformatics.biomedcentral.com/articles/10.1186/s12859-021-04556-z)

## Session Info
```{r}
 sessionInfo()
```