---
title: "51-kp"
output: github_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r}
if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install("karyoploteR")
```

```{r}
library(karyoploteR)
```





```{r}
duck.genome <- toGRanges(data.frame(chr=c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18" ), start=c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ), end=c(89643857,	69596280,	57743597, 65288255, 67248332, 61759565, 43120122, 61151155, 38581958, 53961475, 51449921, 50438331, 44396874, 45393038, 47938513, 31980953, 34923512,	27737463)))
kp <- plotKaryotype(genome = duck.genome)
```



```{r}
gig.genome <- toGRanges(data.frame(chr=c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"), start=c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), end=c(55785328,	73222313,	58319100, 53127865, 73550375, 60151564, 62107823, 58462999, 37089910, 57541580)))
kp <- plotKaryotype(genome = gig.genome)
```


```{r}
plotKaryotype(genome = gig.genome, plot.type=1, ideogram.plotter=kpAddCytobands, labels.plotter=kpAddChromosomeNames, chromosomes="auto", zoom=NULL, cytobands=NULL, plot.params=NULL, use.cache=TRUE, main=NULL)
```




```{r}
set.seed(1000)
rand.data <- createRandomRegions(genome= gig.genome, nregions=10000, length.mean=1, 
                                 length.sd=0, mask=NA, non.overlapping=TRUE)
mcols(rand.data) <- data.frame(y=rnorm(n=10000, mean = 0.5, sd=0.1))
kp <- plotKaryotype(genome = gig.genome, plot.type=1, ideogram.plotter=kpAddCytobands, labels.plotter=kpAddChromosomeNames, chromosomes="auto", zoom=NULL, cytobands=NULL, plot.params=NULL, use.cache=TRUE, main=NULL)
kpPoints(kp, rand.data, pch=".")
```


```{r}
pp <- getDefaultPlotParams(plot.type=1)
pp
```


```{r}
pp$ideogramheight <- 50
pp$dataallmax <- 100
```


```{r}
set.seed(1000)
rand.data <- createRandomRegions(genome= gig.genome, nregions=10000, length.mean=1, 
                                 length.sd=0, mask=NA, non.overlapping=TRUE)
mcols(rand.data) <- data.frame(y=rnorm(n=10000, mean = 0.5, sd=0.1))
kp <- plotKaryotype(genome = gig.genome, plot.type=1, ideogram.plotter=kpAddCytobands, labels.plotter=kpAddChromosomeNames, chromosomes="auto", zoom=NULL, cytobands=NULL, plot.params=pp, use.cache=TRUE, main=NULL)
kpPoints(kp, rand.data, pch=".")
```










