View source: R/bioinfo_sequences.R
grSummaryPerBin | R Documentation |
Summarize a given metric per GRanges
over genomic bins.
grSummaryPerBin(
gr,
colname = NULL,
binwidth = 200,
which.summary = "sum",
plot.it = FALSE,
...
)
gr |
|
colname |
character specifying a given column in |
binwidth |
fixed width of each bin |
which.summary |
names of the summaryzing function (one or several among |
plot.it |
if TRUE, a karyogram will be plotted |
... |
other arguments passed to |
invisible GRanges
containing the bins with the summary
Timothee Flutre
## Not run: ## dummy data
set.seed(1)
C <- 2
P <- C * 10^3
df <- data.frame(CHR=c(rep("chr1", 10^3), rep("chr2", 10^3)),
SNP=paste0("snp", 1:P),
POS=NA,
N=abs(rnorm(P)))
df$POS[df$CHR == "chr1"] <- sort(sample.int(10^5, 10^3))
df$POS[df$CHR == "chr2"] <- sort(sample.int(10^5, 10^3))
head(df)
str(df)
library(GenomicRanges)
df.gr <- GRanges(seqnames=df$CHR, ranges=IRanges(start=df$POS, width=1),
metric=df$N,
seqlengths=c(chr1=10^5, chr2=10^5))
df.gr
(bins <- grSummaryPerBin(gr=df.gr, colname=NULL, binwidth=200))
(bins <- grSummaryPerBin(gr=df.gr, colname="metric", binwidth=200,
which.summary="sum"))
(bins <- grSummaryPerBin(gr=df.gr, colname="metric", binwidth=200,
which.summary="sum", which.plot="sum", plot.it=TRUE))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.