15 class 04
- heat map
val <- mpg$class
num <- 10
df <- expand.grid(y = 1:num, x = 1:num)
df
categ_table <- round(table(val) * ((num*num)/(length(val))))
categ_table
df$category <- factor(rep(names(categ_table), categ_table))
df
ggplot(df, aes(x=x, y=y, fill=category)) +
geom_tile(color="black", size=0.5)
- myexp 데이터로 heatmap
myexp2 <- myexp %>%
rownames_to_column() %>%
slice(1:30) %>%
pivot_longer(-rowname, names_to = "sample_name")
ggplot(myexp2, aes(x=rowname, y=sample_name, fill=value)) +
geom_tile(color="gray", size=0.2) +
theme(
axis.text.x = element_text(angle=90)
) +
scale_fill_viridis_c()
- density plot
myexp %>%
dplyr::select("GSM2462948", "GSM2462949") %>%
rownames_to_column() %>%
pivot_longer(-rowname) %>%
ggplot(aes(x=value, fill=name)) +
geom_histogram() +
scale_x_continuous(trans="log")
myplotdata <- myexp %>%
dplyr::select("GSM2462948", "GSM2462949") %>%
rownames_to_column() %>%
pivot_longer(-rowname)
ggplot(myplotdata, aes(x=value)) +
geom_density(aes(fill=factor(name)), alpha=0.4) +
scale_x_continuous(trans = "log") +
scale_fill_viridis(discrete = T) +
theme_bw()
#install.packages("ggridges")
- ggridges
library(ggridges)
ggplot(myplotdata, aes(x=value)) +
geom_density_ridges(aes(fill=factor(name)), alpha=0.4) +
scale_x_continuous(trans = "log") +
scale_fill_viridis(discrete = T) +
theme_bw()