
python R语言 基础/画图等
R语言相关基础和数据处理实现的,有关生信画图
李子树下mini
这个作者很懒,什么都没留下…
展开
-
python scanpy pl.heatmap 热图 自定义修改
python 借助scanpy工具画热图 heatmap,自定义修改原创 2022-05-26 12:09:49 · 2399 阅读 · 0 评论 -
python pandas 按照列值重新排序,sort_values
df = pd.DataFrame({ 'col1': ['A', 'A', 'B', np.nan, 'D', 'C'], 'col2': [2, 1, 9, 8, 7, 4], 'col3': [0, 1, 9, 4, 2, 3], 'col4': ['a', 'B', 'c', 'D', 'e', 'F']})df col1 col2 col3 col40 A 2 0 a1 A 1 1 B2原创 2022-03-09 20:16:35 · 1853 阅读 · 0 评论 -
plt.scatter 使得图例与matplotlib中的散点颜色相对应
问题描述:如何用Matplotlib在Python中添加散点着色的图例,我有不同颜色不同cluster的,如何给每个cluster上颜色参考:https://datavizpyr.com/add-legend-to-scatterplot-colored-by-a-variable-with-matplotlib-in-python/plt.figure(figsize=(8,6))scatter = plt.scatter(df.culmen_length_mm, df.c原创 2022-01-20 15:07:20 · 2467 阅读 · 0 评论 -
seurat gene expression matrix基因表达矩阵数据
seurat 表达矩阵访问seurat有个active assay,它其中存的就是表达矩阵,用pbmc[[“RNA”]]@counts就可以访问数据标准化后的基因表达矩阵放在:pbmc[[“RNA”]]@data原创 2021-11-26 15:38:51 · 3193 阅读 · 2 评论 -
R语言 不同行数的列/不同长度向量/不同长度列表 合并为dataframe
不同长度向量合并为data.frame># 构造列表> (a_list = list(+ c(1, 1, 2, 5, 14, 42), + month.abb,+ c(1, 1, 2, 5, 14, 42, 22,88, 0)))# [[1]]# [1] 1 1 2 5 14 42# # [[2]]# [1] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"#转载 2021-11-26 11:29:04 · 10329 阅读 · 0 评论 -
R 语言 dotplot 画基因表达量图
R, seurat object, dotplot 在不同细胞类型间的基因表达library(ggplot2)library(ggpubr)features<- c("CD8A","CD14")dotplt = DotPlot(sub.combined, features = features, cols = c('white','#F8766D'),dot.scale=4.5) + RotatedAxis()dotplt = dotplt + theme(axis.text.x = el原创 2021-08-11 17:49:24 · 4124 阅读 · 0 评论 -
R语言 dittoBarPlot画比例图
R语言,object:seurat object,想要实现画出不同cluster里不同来源的比例图library(dittoSeq)d1 <- dittoBarPlot( object = combined.integrated, var = "Group", group.by = "seurat_clusters")d1实现效果原创 2021-08-11 17:44:48 · 989 阅读 · 0 评论 -
R 语言 barplot 画柱状图
R语言画并列的柱状图代码barplot(number_list, main = "seem like title?", beside=TRUE, legend=TRUE, args.legend = list(x ="topright", bty ="n", inset=c(0, 0)), family='SyHei', col=c("pink","cyan"),las=2) # las=2转置横坐标beside=TRUE ,两个轴并列放置las=2,旋转了X轴横坐标的方向更多可参考:htt原创 2021-08-11 17:38:34 · 2200 阅读 · 0 评论 -
R语言 画图坐标文字旋转方向
ggplot画图:rotate_x_text() 转置横坐标的字体,ggpubr 包 barplot画柱状图,las=2转置横坐标原创 2021-08-11 17:27:44 · 4461 阅读 · 0 评论 -
R 语言 画多个合并在一起的小提琴图
R 语言,Seurat object,想要实现多个小提琴图在一个图的效果,想要实现的效果如下所示:library(Seurat)library(SeuratData)library(ggplot2)library(ggpubr)## remove the x-axis text and tick## plot.margin to adjust the white space between each plot.## ... pass any arguments to VlnPlot in原创 2021-08-11 17:24:59 · 4365 阅读 · 3 评论 -
R 统计频数大于某个值的值
例子:实现统计某一列频数大于2的名称a <- c(10,20,30,40,10,20,30,40)b <- c('book', 'pen', 'textbook', 'pencil_case','book', 'pen', 'textbook', 'textbook')df <- data.frame(a,b)# printtable(df$b)[table(df$b)>2]names(table(df$b))[table(df$b)>2]output原创 2021-08-11 17:19:27 · 4351 阅读 · 0 评论