Skip to content

Instantly share code, notes, and snippets.

@mbk0asis
Last active August 24, 2020 07:35
Show Gist options
  • Save mbk0asis/596690df33be2dc933ac0bab51416a85 to your computer and use it in GitHub Desktop.
Save mbk0asis/596690df33be2dc933ac0bab51416a85 to your computer and use it in GitHub Desktop.
dta <- read.csv("file:///C:/Users/bk/Desktop/TEST_data.csv",header = T, row.names = 1)
head(dta)
cl <- kmeans(cntNorm,6)
cluster<-cl$cluster
table(cluster)
rNames <- rownames(cnrNorm)
df<-data.frame(cntNorm, rNames, cluster) # attach cluster info on the data frame
head(df)
library(reshape2)
mdata <- melt(df, id=c("rNames","cluster"))
head(mdata)
# plotting using ggplot2
library(ggplot2)
jit <- position_jitter (width = .08, height = .08)
ggplot(mdata, aes(x=variable, y=log2(1+value), group = rNames)) + theme_bw() +
geom_line(position = jit, colour = alpha("black", 0.1)) +
stat_summary(aes(group = cluster), fun = mean, geom = "line", color="red", size = .5) +
# theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
facet_wrap(~ cluster, ncol = 5, scales = "free")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment