Last active
November 1, 2023 15:26
-
-
Save mikelove/19dd87fdda8536839e3f07a1d2b3df5a to your computer and use it in GitHub Desktop.
Simple exploration of data with tidyverse and tidyomics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(palmerpenguins) # penguins! | |
library(ggplot2) # "grammar of graphics" plots | |
suppressPackageStartupMessages( | |
library(dplyr) # data pliers | |
) | |
penguins |> | |
slice(1:3) |> | |
select(species, island) | |
penguins |> | |
summarize(ave_mass = mean(body_mass_g, na.rm=TRUE)) | |
penguins |> | |
na.omit() |> | |
summarize(ave_mass = mean(body_mass_g)) | |
penguins <- penguins |> | |
na.omit() | |
penguins |> | |
summarize(ave_mass = mean(body_mass_g)) | |
penguins |> | |
group_by(species, island) |> | |
summarize(ave_mass = mean(body_mass_g)) | |
penguins |> | |
ggplot(aes(species, body_mass_g)) + | |
geom_boxplot() | |
scaled <- penguins |> | |
select(contains(c("mm","mass"))) |> | |
mutate(across(everything(), scale)) | |
scaled |> | |
prcomp() | |
pca <- scaled |> | |
prcomp() | |
names(pca) | |
penguins |> | |
bind_cols( pca$x ) |> | |
ggplot(aes(PC1, PC2, color=species)) + | |
geom_point() | |
suppressPackageStartupMessages({ | |
library(macrophage) # some data | |
library(SummarizedExperiment) # experiment object | |
library(tidySummarizedExperiment) # allow dplyr | |
}) | |
data(gse) | |
gse |> | |
distinct(condition) | |
gse |> | |
filter(condition %in% c("naive","IFNg")) |> | |
filter(SYMBOL == "DPM1") |> | |
ggplot(aes(condition_name, counts)) + | |
geom_boxplot() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment