Skip to content

Commit f04e6b2

Browse files
committed
Make QTHist consistent
now QThist will show percentages, rather then frequencies, for single distributions as well as multi-distributions. Also, the numbers param now works in both cases. Fix #179
1 parent 3f41299 commit f04e6b2

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

R/feature-plots.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# @return A vector of genomic distances for each query region relative to its
1818
# closest feature.
1919
calcFeatureDistBioc = function(query, features) {
20-
.validateInputs(list(query=x("GRangesList","GRanges")))
20+
.validateInputs(list(query=c("GRangesList","GRanges")))
2121
if (is(query, "GRangesList")) {
2222
# Recurse over each GRanges object
2323
x = lapply(query, calcFeatureDist, features)
@@ -337,6 +337,7 @@ cutDists = function(dists, divisions=NULL, nbins=50,
337337
labels = labelCuts(sort(divisions), collapse=" to ", infBins=infBins)
338338
cuts = cut(dists, divisions, labels)
339339
df = as.data.frame(table(cuts))
340+
setDT(df)
340341
return(df)
341342
}
342343

R/qthist.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ plotQTHist = function(x, EndBarColor = "gray57", MiddleBarColor = "gray27",
9090
g = ggplot(df, aes(x=cuts, y=Freq, fill=name)) +
9191
facet_wrap(. ~name)
9292
} else {
93+
if (!numbers)
94+
df$Freq = df[, .(Freq.Per = (Freq / sum(Freq)) * 100)]$"Freq.Per"
9395
g = ggplot(df, aes(x=cuts, y=Freq))
9496
}
9597
# Create a vector for the colors
@@ -114,6 +116,10 @@ plotQTHist = function(x, EndBarColor = "gray57", MiddleBarColor = "gray27",
114116
theme(legend.position="bottom") +
115117
geom_text(aes(label= paste((output[["quantile"]]*100),"%", sep='')),
116118
data=df[qbaridx,], hjust=-1, angle=90, size=2.5)
119+
120+
if (!numbers)
121+
g = g + ylab("Percentage")
122+
117123
return(g)
118124
}
119125

man/plotChromBins.Rd

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)