ggplotは、回転した相関プロットを描画します

fff8c50cff8088df390b575f6af5a819.png

注意を払わなかった?ここに指を向けてください-

0856d30e1c1aa77ca7f021dd19d586f6.png

e04c98ae9abe37bcbaed02775d0af774.png

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))
496af58d6b3c3c1e63867557f5c799e4.png

矩形:

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))
f5b76ae5f4e221379d839e0dc8ff920f.png

3エンディング

大丈夫そうです。

ad7b3c821ccdaedad27ad642968c8606.png

04bb9cb5b74437a5443d980d57ce0426.png

Shengxin交換グループへようこそ。私をWeChatに追加してください 。また、WeChatグループチャット 老俊俊生信交流群 に参加します。データコードがQQグループにアップロードされました。参加して、ダウンロードしてください。

グループQRコード

4e18a3459b7102cc2e845d8d6d1803ae.png


Lao Junjun WeChat:

51722d3513dc5245a2949a4318670dda.png

知識の惑星:

c7aa17669d6b4c6df6cdd40c4f99dd61.png

今日は勉強しましたか?

今日の共有は以上です。次の共有にご期待ください。

最後に、みんなが共有して転送することを歓迎します、あなたの好きなものは私の励まし肯定です!

お役に立てれば幸いです!

 過去のレビュー 

Rsamtoolsバッチ処理bamファイル

濃縮分析と視覚化のためのGSEApy

pysamはbamファイルを読み取り、Ribo-seqQCデータを準備します

美しいサンキーダイアグラムを描くためのサンキーホイール

ggplotはバイオリン図+箱ひげ図+統計的検定を描画します

Ribo-seqデータの上流分析

シーケンス抽出の問題について考える

◀CellReportsでグラフを作成する方法を学ぶ-CLIP-seqデータの視覚化

ピーク中心のm6A濃縮

m6Aメタ遺伝子分布修正された座標

◀..。

おすすめ

転載: blog.csdn.net/weixin_45822007/article/details/124223979