Skip to content

Instantly share code, notes, and snippets.

View stephaniehicks's full-sized avatar

Stephanie Hicks stephaniehicks

View GitHub Profile
@stephaniehicks
stephaniehicks / 2020-10-hicks-genomicsranges-plyranges.R
Last active October 21, 2020 09:27
Demo for the Introduction to GenomicRanges and plyranges by Stephanie Hicks (2020-10-06)
library(GenomicRanges)
library(plyranges)
## Create a GRanges object
gr <- GRanges(seqnames = "chr1",
strand = c("+", "-"),
ranges = IRanges(start = c(102012,520211),
end=c(120303, 526211)),
gene_id = c(1001,2151),
score = c(10, 25))
@stephaniehicks
stephaniehicks / SamplingPointsBasedOnIntensity.r
Created February 8, 2017 20:10
Sample points from an image based on intensity
library(jpeg) # or png, depending on your image (replace readJPEG with readPNG)
y <- readJPEG("rafa.jpeg") # You can get this off Google if you want to test it.
jpeg("channels1to3.jpeg", width = 1200, height = 800)
par(mfrow=c(2,3))
image(y[,,1], main = "Channel 1")
image(y[,,2], main = "Channel 2")
image(y[,,3], main = "Channel 3")
image(y[,,1], main = "Channel 1", col = rgb(seq(0, 1, by = 0.05), 0, 0))
image(y[,,2], main = "Channel 2", col = rgb(0, seq(0, 1, by = 0.05), 0))
@stephaniehicks
stephaniehicks / ASA_Awards.r
Created February 6, 2017 21:09
Scape ASA Awards website
library(rvest)
library(stringr)
urlpage <- "http://www.amstat.org/ASA/Your-Career/Awards-and-Scholarships.aspx"
awards <- read_html(urlpage)
awardTitles <- awards %>%
html_nodes("#ctl00_TemplateBody_WebPartManager1_gwpciNewContentHtml_ciNewContentHtml_Panel_NewContentHtml a") %>% html_text()
awardURLs <- awards %>%
@stephaniehicks
stephaniehicks / cowplot
Last active August 29, 2015 14:26
arrange ggplot2 plots in a grid using cowplot
library(cowplot)
library(ggplot2)
library(PASWR)
data(Cows) # already in a "tidy" format
box.cow <- ggplot(Cows, aes(x = breed, y = butterfat, fill = age)) +
geom_boxplot() + labs(title = "Default cowplot theme")
save_plot("boxCow.jpeg", box.cow)
---
title: "UF Department of Statistics Job Postings"
author: "Stephanie Hicks"
date: "23 Feb 2015"
output: html_document
keep_md: TRUE
---
## Purpose
@stephaniehicks
stephaniehicks / halloweenPoissonProcess
Last active August 29, 2015 14:08
Simulating trick-or-treaters as a Poisson Process
# Load library
library(ggplot2)
# ToT = Trick-or-Treators
tEnd = 3*60*60 # 3 hours (in seconds)
lambdaMin = 1 # Define the rate as 1 ToT per minute
lambdaSec = lambdaMin/60 # converted rate in ToT per second
# Randomly inter-arrival times between ToT using an exponential distribution
t = 0; k = 0
@stephaniehicks
stephaniehicks / clean.tweets
Created June 10, 2014 18:58
Clean the tweets from searchTwitter()
clean.tweets <- function(some_txt)
{
some_txt = gsub("&amp", "", some_txt)
some_txt = gsub("(RT|via)((?:\\b\\W*@\\w+)+)", "", some_txt)
some_txt = gsub("@\\w+", "", some_txt)
some_txt = gsub("[[:punct:]]", "", some_txt)
some_txt = gsub("[[:digit:]]", "", some_txt)
some_txt = gsub("http\\w+", "", some_txt)
some_txt = gsub("[ \t]{2,}", "", some_txt)
some_txt = gsub("^\\s+|\\s+$", "", some_txt)
@stephaniehicks
stephaniehicks / MathJax_for_Jekyll
Created May 7, 2014 23:15
HTML code to add MathJax to a Jekyll Blog
<!-- mathjax javascript -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
</script>
<script type="text/javascript" src="https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>