注意を払わなかった?ここに指を向けてください-
1はじめに
文献では、回転、インターネットを検索し、それらをあなたと共有します。
2図面
library(ggplot2)
library(grid)
# 加载内置数据集
data('mtcars')
# 计算相关性系数
corda <- data.frame(cor(mtcars))
# 上三角操作
corda[upper.tri(corda)] <- NA
# # 计算相关性系数
# corda <- data.frame(cor(mtcars))
#
# # 下三角操作
# corda[lower.tri(corda)] <- NA
# 加载R包
library(reshape2)
library(tidyverse)
# 增加行名列
corda$y <- rownames(corda)
# 宽数据转长数据
da <- melt(data = corda) %>% na.omit()
# 因子化
da$variable <- factor(da$variable,levels = unique(da$variable))
da$y <- factor(da$y,levels = unique(da$y))
# squre
p <- ggplot(da) +
# 矩形图层
geom_tile(aes(x = variable,y = y),fill = 'white',
show.legend = F,
color = 'grey80',size = 1) +
# 点图层
geom_point(aes(x = variable,y = y,fill = value,size = value),
show.legend = F,
shape = 21,color = 'black') +
theme_minimal() +
# 主题调整
theme(panel.grid = element_blank(),
aspect.ratio = 1,
axis.text = element_text(color = 'black',size = 20),
axis.text.x = element_text(angle = 45,hjust = 0),
axis.text.y = element_text(angle = 45,hjust = 1)) +
# x轴标签位置
scale_x_discrete(position = 'top') +
# 点颜色
scale_fill_gradientn(colors = colorRampPalette(c("#019267", "white", "red"))(10)) +
# 点大小范围
scale_size(range = c(7,14)) +
# 图例设置
guides(size = 'none',fill = guide_colorbar(title = 'Corr',
barwidth = 1.5,barheight = 15,
frame.colour = 'black',
ticks.colour = "black")) +
xlab('') + ylab('')
print(p, vp = viewport(width = unit(0.5, "npc"),
height = unit(0.5, "npc"), angle = -45))
矩形:
p <- ggplot(da) +
# 矩形图层
geom_tile(aes(x = variable,y = y,fill = value),
show.legend = F,
color = 'grey80',size = 1) +
# # 点图层
# geom_point(aes(x = variable,y = y,fill = value,size = value),
# show.legend = F,
# shape = 21,color = 'black') +
theme_minimal() +
# 主题调整
theme(panel.grid = element_blank(),
aspect.ratio = 1,
axis.text = element_text(color = 'black',size = 16),
axis.text.x = element_text(angle = 45,hjust = 0),
axis.text.y = element_text(angle = 45,hjust = 1)) +
# x轴标签位置
scale_x_discrete(position = 'top') +
# 点颜色
scale_fill_gradientn(colors = colorRampPalette(c("#398AB9", "white", "red"))(10)) +
# 点大小范围
scale_size(range = c(7,14)) +
xlab('') + ylab('')
print(p, vp = viewport(width = unit(0.8, "npc"),
height = unit(0.8, "npc"), angle = -45))
3エンディング
大丈夫そうです。
Shengxin交換グループへようこそ。私をWeChatに追加してください 。また、WeChatグループチャット 老俊俊生信交流群
に参加します。データコードがQQグループにアップロードされました。参加して、ダウンロードしてください。
グループQRコード:
Lao Junjun WeChat:
知識の惑星:
今日は勉強しましたか?
今日の共有は以上です。次の共有にご期待ください。
最後に、みんなが共有して転送することを歓迎します、あなたの好きなものは私の励ましと肯定です!
お役に立てれば幸いです!
過去のレビュー
◀ pysamはbamファイルを読み取り、Ribo-seqQCデータを準備します
◀ ggplotはバイオリン図+箱ひげ図+統計的検定を描画します
◀CellReportsでグラフを作成する方法を学ぶ-CLIP-seqデータの視覚化
◀..。