計(jì)算gc含量
seqkit.exe fx2tab --name --only-id --gc output.fasta -o gc.txt
image.png
計(jì)算序列長(zhǎng)度
seqkit.exe fx2tab --name --only-id -l output.fasta -o seqlen.txt
image.png
ggpairs更改配色
這個(gè)只是一種方案坯苹,還有好多問題沒有解決,比如如何給下三角和上三角賦予不同的顏色
代碼
library(GGally)
ggpairs(iris,columns = 1:4,
lower = list(continuous="points",
mapping=aes(color=Species)),
diag = list(continuous="densityDiag",
mapping=aes(fill=Species)),
upper = list(continuous="cor",
mapping=aes(colour=Species)))+
scale_color_manual(values=c("red","blue","green"))+
scale_fill_manual(values = c("orange","yellow","purple"))+
theme_bw()
image.png
歡迎大家關(guān)注我的公眾號(hào)
小明的數(shù)據(jù)分析筆記本
小明的數(shù)據(jù)分析筆記本 公眾號(hào) 主要分享:1、R語言和python做數(shù)據(jù)分析和數(shù)據(jù)可視化的簡(jiǎn)單小例子为鳄;2孤钦、園藝植物相關(guān)轉(zhuǎn)錄組學(xué)、基因組學(xué)静袖、群體遺傳學(xué)文獻(xiàn)閱讀筆記俊扭;3萨惑、生物信息學(xué)入門學(xué)習(xí)資料及自己的學(xué)習(xí)筆記!
ggplot2 作圖 極坐標(biāo)情況下添加直線
自己沒有想法如何實(shí)現(xiàn)解总,搜索引擎搜索關(guān)鍵詞 ggplot2 polar and then add straight lines
找到參考鏈接
代碼暫時(shí)還看不明白倾鲫,他是自己重新定義了一個(gè)函數(shù)乌昔,代碼我先復(fù)制過來,后面有時(shí)間來研究
library(tidyverse)
library(ggplot2)
df <- tibble(x = rep(letters, each = 5),
y = rep(1:5, 26),
d = rnorm(26 * 5))
p1 <- ggplot() +
geom_tile(data = df,
aes(x = x,
y = y,
fill = d)) +
ylim(c(-2, 5)) +
geom_segment(
aes(
x = "o",
y = -1,
xend = "z",
yend = 3
),
arrow = arrow(length = unit(0.2, "cm")),
col = "red",
size = 2
)
p1
image.png
p1 + coord_polar()
image.png
自定義函數(shù)
geom_segment_straight <- function(...) {
layer <- geom_segment(...)
new_layer <- ggproto(NULL, layer)
old_geom <- new_layer$geom
geom <- ggproto(
NULL, old_geom,
draw_panel = function(data, panel_params, coord,
arrow = NULL, arrow.fill = NULL,
lineend = "butt", linejoin = "round",
na.rm = FALSE) {
data <- ggplot2:::remove_missing(
data, na.rm = na.rm, c("x", "y", "xend", "yend",
"linetype", "size", "shape")
)
if (ggplot2:::empty(data)) {
return(zeroGrob())
}
coords <- coord$transform(data, panel_params)
# xend and yend need to be transformed separately, as coord doesn't understand
ends <- transform(data, x = xend, y = yend)
ends <- coord$transform(ends, panel_params)
arrow.fill <- if (!is.null(arrow.fill)) arrow.fill else coords$colour
return(grid::segmentsGrob(
coords$x, coords$y, ends$x, ends$y,
default.units = "native", gp = grid::gpar(
col = alpha(coords$colour, coords$alpha),
fill = alpha(arrow.fill, coords$alpha),
lwd = coords$size * .pt,
lty = coords$linetype,
lineend = lineend,
linejoin = linejoin
),
arrow = arrow
))
}
)
new_layer$geom <- geom
return(new_layer)
}
畫圖代碼
ggplot() +
geom_tile(data = df,
aes(x = x,
y = y,
fill = d)) +
ylim(c(-2, 5)) +
geom_segment_straight(
aes(
x = "o",
y = -1,
xend = "z",
yend = 3
),
arrow = arrow(length = unit(0.2, "cm")),
col = "red",
size = 2
) +
coord_polar()
image.png
曲線也是可以的
geom_curve_polar <- function(...) {
layer <- geom_curve(...)
new_layer <- ggproto(NULL, layer)
old_geom <- new_layer$geom
geom <- ggproto(
NULL, old_geom,
draw_panel = function(data, panel_params, coord,
curvature = 0.5, angle = 90, ncp = 5,
arrow = NULL, arrow.fill = NULL,
lineend = "butt", linejoin = "round",
na.rm = FALSE) {
data <- ggplot2:::remove_missing(
data, na.rm = na.rm, c("x", "y", "xend", "yend",
"linetype", "size", "shape")
)
if (ggplot2:::empty(data)) {
return(zeroGrob())
}
coords <- coord$transform(data, panel_params)
ends <- transform(data, x = xend, y = yend)
ends <- coord$transform(ends, panel_params)
arrow.fill <- if (!is.null(arrow.fill)) arrow.fill else coords$colour
return(grid::curveGrob(
coords$x, coords$y, ends$x, ends$y,
default.units = "native", gp = grid::gpar(
col = alpha(coords$colour, coords$alpha),
fill = alpha(arrow.fill, coords$alpha),
lwd = coords$size * .pt,
lty = coords$linetype,
lineend = lineend,
linejoin = linejoin
),
curvature = curvature, angle = angle, ncp = ncp,
square = FALSE, squareShape = 1, inflect = FALSE, open = TRUE,
arrow = arrow
))
}
)
new_layer$geom <- geom
return(new_layer)
}
ggplot() +
geom_tile(data = df,
aes(x = x,
y = y,
fill = d)) +
ylim(c(-2, 5)) +
geom_curve_polar(
aes(
x = "o",
y = -1,
xend = "z",
yend = 3
),
arrow = arrow(length = unit(0.2, "cm")),
col = "red",
size = 2
) +
coord_polar()
image.png