scatter plot with categorical data using ggplot2

gene_x 0 like s 476 view s

Tags: plot

load packages

library(tidyverse)
library(palmerpenguins)
library(ggbeeswarm)
library(ggforce)

#remotes::install_github("allisonhorst/palmerpenguins")
# peek at penguins data
#glimpse(penguins)

# create some example data
x <- c(rep("A", 100), rep("B", 100), rep("C", 100))
y <- rnorm(300)

# create a data frame with x, y, and color columns
df <- data.frame(x = x, y = y, color = ifelse(c(1:300) %in% c(5, 10, 15), "Highlighted", "Normal"))

#  geom_point(size = 3) +
# plot the data with points colored by category and highlight
ggplot(df, aes(x = x, y = y, color = color)) +
  scale_color_manual(values = c("Normal" = "black", "Highlighted" = "red")) +
  geom_beeswarm(cex = 1.5) +
  theme_classic()

 #In this script, we use ggplot2 to create a scatter plot with categorical data and highlight some points. We start by creating an example dataset with a categorical variable x and a continuous variable y. We then create a data frame df with x, y, and color columns. The color column is set to "Highlighted" for the points we want to highlight, and "Normal" for the rest.

 #We then use ggplot2 to plot the data. We set x, y, and color to the corresponding columns in df using the aes() function. We use geom_point() to plot the points, and set the size argument to control the size of the points. We use scale_color_manual() to set the colors for the "Normal" and "Highlighted" categories. Finally, we use theme_classic() to set the theme of the plot to a classic theme.

like unlike

点赞本文的读者

还没有人对此文章表态


本文有评论

没有评论

看文章,发评论,不要沉默

最受欢迎文章

  1. Why Do Significant Gene Lists Change After Adding Additional Conditions in Differential Gene Expression Analysis?
  2. Motif Discovery in Biological Sequences: A Comparison of MEME and HOMER
  3. Calling peaks using findPeaks of HOMER
  4. Updating Human Gene Identifiers using Ensembl BioMart: A Step-by-Step Guide
  5. pheatmap vs heatmap.2
  6. Setup conda environments
  7. Should the inputs for GSVA be normalized or raw?
  8. File format for single channel analysis of Agilent microarray data with Limma?
  9. Kraken2 Installation and Usage Guide
  10. PiCRUST2 Pipeline for Functional Prediction and Pathway Analysis in Metagenomics

最新文章


最多评论文章


推荐相似文章

Enhanced Visualization of Gene Presence for the Selected Genes in Bongarts_S.epidermidis_HDRNA

Identify all occurrences of Phages MT880870, MT880871 and MT880872 in S. epidermidis ST2 genomes from public and clinical isolates

Identify all occurrences of Phage HH1 MT880870 in S. epidermidis ST2 genomes from public and clinical isolates

YopQ Secretion Boxplot and Fitting Function


© 2023 XGenes.com Impressum