问题:我将ggsave应用在pipe %>%符号中,报错! grid.draw") : "grid.draw"没有适用于"c('LayerInstance', 'Layer', 'ggproto', 'gg')"目标对象的方法 ❞ 查阅了资料,ggplot2中调用ggsave ("plot2.png") 这里,直接用+连接ggsave,而不是%>%文件如下: ? 这里面,用()将ggplot作图的代码括住,它会输出到屏幕上,使用%>%将其作为对象传递给ggsave,用.表示它,写作ggsave("plot3.png",.),即可。 保存文件: ? 4. 之前作图,都是用png(),或者pdf(),调用,然后用dev.off()关掉保存,发现了ggsave保存图片很方便,真得很方便。就灌水文一篇。
sce <- RunUMAP(object = sce, dims = 1:15, do.fast = TRUE) DimPlot(sce,reduction = "umap",label=T) ggsave sce, resolution = 0.2) table(sce@meta.data$seurat_clusters) DimPlot(sce,reduction = "umap",label=T) ggsave p <- DotPlot(sce, features = unique(genes_to_check), assay='RNA' ) + coord_flip() p ggsave /check_RV_marker_by_seurat_cluster.pdf") p_umap<-DimPlot(sce,reduction = "umap",label=T ) p+p_umap ggsave split.by = "group",flip = T,stack = T,cols = c("red","grey"), split.plot =T );v1 ggsave
("DimPlot_imm_Normal_Tumor.pdf", path = "output/fig4", width = 15, height = 15, units = "cm") #ggsave2 = 15, units = "cm") DimPlot(imm_anno, group.by = "patient_id", cols = use_colors, pt.size = 0.5) #ggsave2 (imm_anno, group.by = "cell_type_imm", split.by = "tissue_type", cols = use_colors, pt.size = 0.5) #ggsave2 theme(axis.text.x = element_text(angle = 90, hjust = 1)) + coord_flip() + scale_color_viridis() ggsave2 position = "fill") + scale_fill_manual(values = use_colors) + coord_flip() + scale_y_reverse() ggsave2
') write.csv(embed_tsne,'subcluster/embed_tsne.csv') plot1 = DimPlot(scRNAsub, reduction = "tsne") ggsave ("subcluster/tSNE.pdf", plot = plot1, width = 8, height = 7) ggsave("subcluster/tSNE.png", plot = plot1 ("subcluster/UMAP.pdf", plot = plot2, width = 8, height = 7) ggsave("subcluster/UMAP.png", plot = plot2 /tSNE_UMAP.pdf", plot = plotc, width = 10, height = 5) ggsave("subcluster/tSNE_UMAP.png", plot = plotc =7 ,height=6) ggsave("subcluster/celltype.pdf", p3, width=10 ,height=5) ggsave("subcluster/celltype.png
('degs_compareCluster-BP_enrichment--3.pdf',plot = p,width = 13,height = 40,limitsize = F) ggsave ('degs_compareCluster-CC_enrichment--3.pdf',plot = p,width = 13,height = 40,limitsize = F) ggsave ('degs_compareCluster-MF_enrichment--3.pdf',plot = p,width = 13,height = 40,limitsize = F) ggsave ('degs_compareCluster-GO_enrichment--3.pdf',plot = p,width = 13,height = 40,limitsize = F) ggsave ('degs_compareCluster-BP_enrichment--3.pdf',plot = p,width = 13,height = 40,limitsize = F) ggsave
x = rnorm(100), y = rnorm(100) ) # 创建散点图 ggplot(df, aes(x=x, y=y)) + geom_point() + xlab("育种") ggsave ("plot1.tiff") ggplot(df, aes(x=x, y=y)) + geom_point() + xlab("数据") ggsave("plot2.tiff") ggplot(df , aes(x=x, y=y)) + geom_point() + xlab("分析") ggsave("plot3.tiff") ggplot(df, aes(x=x, y=y)) + geom_point () + xlab("之") ggsave("plot4.tiff") ggplot(df, aes(x=x, y=y)) + geom_point() + xlab("放飞") ggsave("plot5 .tiff") ggplot(df, aes(x=x, y=y)) + geom_point() + xlab("自我") ggsave("plot6.tiff") ## 读取 library(
: sce pro='Cd4-Tcells_sub' p <- plotExprs(sce, color_by = "condition") p$facet$params$ncol <- 3 p ggsave2 ) # PCA-based non-redundancy score (NRS) plotNRS(sce, features = "type", color_by = "condition") ggsave2 p2 <- p2 + theme(legend.position = "none") plot_grid(p1, p2, lgd, nrow = 1, rel_widths = c(5, 5, 2)) ggsave2 umap_vs_tSNE.pdf')) # facet by sample plotDR(sce, "TSNE", color_by = "meta10", facet_by = "sample_id") ggsave2 plotDR(sce, "UMAP", color_by = "meta8")) plotAbundances(sce, k = "meta10", by = "sample_id") ggsave2
= "tissue_type", cols.use = list(tissue_type = use_colors), draw.lines = F) + scale_fill_viridis()#ggsave2 ("HeatMap_Macro.pdf", path = "output/fig4", width = 30, height = 40, units = "cm")ggsave2("SuppFig7B.png /results", width = 30, height = 40, units = "cm")#ggsave2("HeatMap_Macro.emf", path = "output/fig4", ("HeatMap_T.pdf", path = "output/fig4", width = 30, height = 35, units = "cm")没有出来,怀疑是heatmap没有加载出来ggsave2 /results", width = 30, height = 35, units = "cm")#ggsave2("HeatMap_T.emf", path = "output/fig4", width
$gene, group.by = "patient_id", draw.lines = F, group.colors = use_colors) + scale_fill_viridis() ggsave2 ("HeatMap_Tumor.pdf", path = "output/fig2", width = 30, height = 30, units = "cm") ggsave2("Fig2C.png geom_bar(position = "fill", width = 0.75) + scale_fill_manual(values = use_colors) + coord_flip() ggsave2 = sample_id, values_from = avg) %>% column_to_rownames("Pathway") %>% as.matrix() ##这里画图的时候我发现还是ggsave ("DimHeatmap_epitumor_PC1.pdf", path = "output/fig2", width = 10, height = 20, units = "cm") ggsave2(
"log10(TSS Enrichment+1)" ) + ggtitle(paste0("GMM classification:\n",i," log10(fragments)")) #+ ggsave "log10(TSS Enrichment+1)" ) + ggtitle(paste0("GMM classification:\n",i," TSS Enrichment")) #+ ggsave log10(df.depth$proj.i.nFrags)),linetype = "dashed") + ggtitle(paste0("QC thresholds:\n",i)) #+ ggsave df.depth$proj.i.nFrags)),linetype = "dashed") + ggtitle(paste0("Doublet Enrichment:\n",i)) #+ ggsave = "log10(TSS Enrichment+1)" ) + ggtitle(paste0("GMM classification:\n",i," log10(fragments)")) ggsave
("QC/vlnplot_before_qc.pdf", plot = violin, width = 12, height = 6) ggsave("QC/vlnplot_before_qc.png ("QC/vlnplot_after_qc.pdf", plot = violin, width = 12, height = 6) ggsave("QC/vlnplot_after_qc.png", ("CellType/tSNE_celltype_DICE.png", p4, width=7 ,height=6) ggsave("CellType/UMAP_celltype_DICE.png", p5, width=7 ,height=6) ggsave("CellType/celltype_DICE.png", p6, width=10 ,height=5) #对比两种数据库鉴定的结果 p8 = p1+p4 ggsave("CellType/Monaco_DICE.png", p8, width=12 ,height=5) ##保存数据 saveRDS(scRNA,'scRNA.rds')
0.01, ncol = 3, same.y.lims=T) + scale_y_continuous(breaks=seq(0, 100, 5)) + NoLegend() p2 ggsave ) p3=FeatureScatter(sce.all, "nCount_RNA", "nFeature_RNA", group.by = "orig.ident", pt.size = 0.5) ggsave features = c("S.Score", "G2M.Score"), group.by = "orig.ident", ncol = 2, pt.size = 0.1) ggsave ) p1=VlnPlot(sce.all, features = feats, pt.size = 0, ncol = 2) + NoLegend() p1 library(ggplot2) ggsave = 0, ncol = 3, same.y.lims=T) + scale_y_continuous(breaks=seq(0, 100, 5)) + NoLegend() p2 ggsave
.]`, y=`mean Colonization [log10(CFU/mg)]`))+ geom_point(aes(color=Phylum))+ ggsave geom_smooth(method = "lm", formula = "y~x", se=F, color="grey")+ ggsave label=expression(italic(R)~"="~0.49~","~italic(P)~"="~5.4%*%10^-15), parse=T)+ ggsave 4.5, ymax = 7, alpha=0, color="black", lty="dashed")+ ggsave = element_blank())+ scale_fill_manual(values = colors)+ scale_color_manual(values = colors)+ ggsave
#排序 mycds <- orderCells(mycds) #State轨迹分布图 plot1 <- plot_cell_trajectory(mycds, color_by = "State") ggsave ("pseudotime/State.pdf", plot = plot1, width = 6, height = 5) ggsave("pseudotime/State.png", plot = plot1 ("pseudotime/Cluster.pdf", plot = plot2, width = 6, height = 5) ggsave("pseudotime/Cluster.png", plot ("pseudotime/Pseudotime.pdf", plot = plot3, width = 6, height = 5) ggsave("pseudotime/Pseudotime.png" ", plot = plotc, width = 10, height = 3.5) ggsave("pseudotime/Combination.png", plot = plotc, width =
= "FCN1") p2 = RidgePlot(scRNA, features = "PC_2") plotc = p1/p2 + plot_layout(guides = 'collect') ggsave p2 = VlnPlot(scRNA, features = "CD8A", pt.size = 0) plotc = p1/p2 + plot_layout(guides = 'collect') ggsave , reduction = 'umap') p2 <- FeaturePlot(scRNA,features = "CD79A", reduction = 'umap') plotc = p1|p2 ggsave 点图 genelist = c('LYZ','CD79A','CD8A','CD8B','GZMB','FCGR3A') p = DotPlot(scRNA, features = genelist) ggsave - DimPlot(scRNA, reduction = 'umap', group.by = "seurat_clusters", label=T) plotc = (p1|p2)/(p3|p4) ggsave
group.by = "orig.ident", features = feats, pt.size = 0.01, ncol = 2) + NoLegend() library(ggplot2) ggsave (filename="Vlnplot1.pdf",plot=p1) ggsave(filename="Vlnplot1.png",plot=p1) feats <- c("percent_mito", ) p3=FeatureScatter(sce.all, "nCount_RNA", "nFeature_RNA", group.by = "orig.ident", pt.size = 0.5) ggsave features = c("S.Score", "G2M.Score"), group.by = "orig.ident", ncol = 2, pt.size = 0.1) ggsave unique(genes_to_check), assay='RNA' ,group.by = 'seurat_clusters' ) + coord_flip() p ggsave
pattern = "outgoing", k = nPatterns) # river plot p = netAnalysis_river(cellchat, pattern = "outgoing") ggsave pattern = "incoming", k = nPatterns) # river plot p = netAnalysis_river(cellchat, pattern = "incoming") ggsave = "functional") # Visualization in 2D-space p = netVisual_embedding(cellchat, type = "functional") ggsave custer_pathway_function.png", p, width = 9, height = 6) p = netVisual_embeddingZoomIn(cellchat, type = "functional") ggsave = "structural") # Visualization in 2D-space p = netVisual_embedding(cellchat, type = "structural") ggsave
p = DotPlot(scRNA, features = nichenet_output$top_ligands, split.by = "aggregate") + RotatedAxis() ggsave ## 查看配体调控靶基因 p = nichenet_output$ligand_target_heatmap ggsave("Heatmap_ligand-target.png", p, width = xlab("anti-LCMV response genes in CD8 T cells") + ylab("Prioritized immmune cell ligands") ggsave ## 查看受体情况 # 查看配体-受体互作 p = nichenet_output$ligand_receptor_heatmap ggsave("Heatmap_ligand-receptor.png the literature and not predicted based on PPI p = nichenet_output$ligand_receptor_heatmap_bonafide ggsave
p2 <- p2 + theme(legend.position = "none") plot_grid(p1, p2, lgd, nrow = 1, rel_widths = c(5, 5, 2)) ggsave2 umap_vs_tSNE.pdf')) # facet by sample plotDR(sce, "TSNE", color_by = "meta20", facet_by = "sample_id") ggsave2 TSNE_by_samples.pdf')) # facet by condition plotDR(sce, "TSNE", color_by = "meta20", facet_by = "condition") ggsave2 plotDR(sce, "UMAP", color_by = "meta8")) plotAbundances(sce, k = "meta20", by = "sample_id") ggsave2 plotAbundances_barplot.pdf')) plotAbundances(sce, k = "meta20", by = "cluster_id", shape_by = "patient_id") ggsave2
p2_tree ggsave(p2_tree, filename = paste0(".. ----------- p1 <- DimPlot(sce.all,group.by = "celltype",label = T,reduction = "tsne",pt.size = 1.5) ggsave ------- p3 <- DimPlot(sce.all,group.by = "celltype",label = T,reduction = "tsne",pt.size = 1.5) p3 ggsave ------- p5 <- DimPlot(sce.all,group.by = "celltype",label = T,reduction = "tsne",pt.size = 1.5) p5 ggsave /picture/Annotation/figure3.Rdata") ps <- p1/p2|p3/p4|p5/p6 ps ggsave(ps,filename = "..