Skip to content

Instantly share code, notes, and snippets.

View Swarchal's full-sized avatar

Scott Warchal Swarchal

View GitHub Profile
@Swarchal
Swarchal / reverse_complement_R.ipynb
Last active January 28, 2016 23:37
puzzle club 3: reverse complement DNA sequence
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Swarchal
Swarchal / GC_Julia.ipynb
Last active January 26, 2016 19:27
puzzle club 3: Calculating GC content
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/sh
# script to update R
sudo add-apt-repository "deb http://cran.rstudio.com/bin/linux/ubuntu $(lsb_release -cs)/"
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
sudo add-apt-repository -y "ppa:marutter/rrutter"
sudo add-apt-repository -y "ppa:marutter/c2d4u"
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends r-base-dev r-recommended qpdf
ggplot(data = df_molten,
aes(x = variable, y = MouseID, fill = value)) +
geom_raster() +
xlab("Protein") +
scale_fill_distiller(palette = "RdYlBu", trans = "log10") + # better colourmap
theme(axis.text.x = element_text(angle = 90, hjust = 1),
axis.text.y = element_blank()) +
ggtitle("ggplot heatmap") +
facet_wrap(~class, scales = "free", ncol = 2)
dat <- df_expression[,2:78] # numerical columns
rownames(dat) <- df_expression[,1]
row.order <- hclust(dist(dat))$order # clustering
col.order <- hclust(dist(t(dat)))$order
dat_new <- dat[row.order, col.order] # re-order matrix accoring to clustering
df_molten_dat <- melt(as.matrix(dat_new)) # reshape into dataframe
names(df_molten_dat)[c(1:2)] <- c("MouseID", "Protein")
ggplot(data = df_molten_dat,
@Swarchal
Swarchal / heatmap.R
Last active September 27, 2019 22:02
heatmap.R
library(ggplot2)
library(reshape2)
df_expression <- read.csv("expression.csv")
df_molten <- melt(df_expression)
ggplot(data = df_molten,
aes(x = variable, y = MouseID, fill = value)) +
geom_raster() +
xlab("Protein") +
scale_fill_distiller(palette = "RdYlBu", trans = "log10") +
# change colours of channels
plotRGB(image_stack, stretch = 'lin' g = 2, b = 1)
# merge channels
image_stack <- brick(image_DNA, image_actin)
# display merged image
plotRGB(image_stack, stretch = 'lin')
# display images
plot(image_DNA, col = gray.colors(max(values(image_DNA))))
plot(image_actin, col = gray.colors(max(values(image_actin))))