Skip to content

Instantly share code, notes, and snippets.

View mikelove's full-sized avatar

Michael Love mikelove

View GitHub Profile
@mikelove
mikelove / sync.sh
Last active February 10, 2018 22:24
#!/bin/bash
for p in DESeq2 apeglm tximport; do
echo "----- syncing $p -----";
cd $p/github/$p
git pull
git fetch --all
git merge upstream/master
git push
cd ../../..
done;
@mikelove
mikelove / app.R
Created February 9, 2018 19:31
nearPoints example
library(shiny)
ui <- fluidPage(mainPanel(
plotOutput("plot1", click="plot_click"),
plotOutput("plot2")
))
server <- function(input, output) {
output$plot1 <- renderPlot({
plot(x,y)
})
output$plot2 <- renderPlot({
@mikelove
mikelove / app.R
Last active February 10, 2018 15:13
nearPoints with persistent points
library(shiny)
library(ggplot2)
ui <- fluidPage(mainPanel(
plotOutput("plot1", click="plot_click")
))
server <- function(input, output) {
selected <- reactive({
near <- nearPoints(dat,input$plot_click,maxpoints=1,"x","y",threshold=20)
if (nrow(near) > 0) {
selected_points <<- near
suppressPackageStartupMessages(library(plyranges))
suppressPackageStartupMessages(library(AnnotationHub))
suppressPackageStartupMessages(library(TxDb.Hsapiens.UCSC.hg19.knownGene))
ah <- AnnotationHub()
query(ah, c("K562","CTCF","unipk"))
peaks <- ah[["AH22543"]]
peaks <- peaks %>% keepStandardChromosomes(pruning.mode="coarse")
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
@mikelove
mikelove / stickers.R
Created June 21, 2018 03:09
stickers
library(hexSticker)
library(rafalib)
e <- expression({
nullplot(bty="n",xaxt="n",yaxt="n")
text(.5,.5,"⇲",cex=15,col="white")
})
set.seed(1)
sticker(e, p_size=24,
s_x=.8, s_y=.6, s_width=.2, s_height=.2,
url="www.bioconductor.org", u_color="white", u_size=4.5,
@mikelove
mikelove / fastq-dump.txt
Created June 29, 2018 13:26
fastq-dump
sudo apt install sra-toolkit
fastq-dump -X 1000000 --split-files SRR1039508
@mikelove
mikelove / stageR.R
Last active July 4, 2019 20:03
stage-wise vs not using stage-wise framework
library(DEXSeq)
alpha1 <- .1
alpha2 <- .01
ngene <- 5000
sig.ratio <- .1
niso <- 5
set.seed(1)
fdr <- replicate(100, {
gene <- factor(rep(1:ngene,each=niso))
pval <- runif(ngene*niso)
@mikelove
mikelove / tximeta.R
Last active July 15, 2018 19:33
tximeta demo
dir <- system.file("extdata/salmon", package="tximportData")
ids <- list.files(dir)
# here gzipped, normally these are not
files <- file.path(dir, ids, "quant.sf.gz")
file.exists(files)
coldata <- data.frame(files, names=ids, population="TSI", stringsAsFactors=FALSE)
library(tximeta)
@mikelove
mikelove / rowdata.R
Last active July 25, 2018 20:46
SummarizedExperiment apparently missing validity check on re-assignment of rownames of rowData
# this is using SummarizedExperiment v1.11.5
suppressPackageStartupMessages(library(SummarizedExperiment))
m <- matrix(1:20, nrow=5, ncol=4, dimnames=list(letters[1:5], LETTERS[1:4]))
# this gives an error, good.
rowdata <- data.frame(x=1:5, row.names=letters[5:1])
se <- SummarizedExperiment(m, rowData=rowdata)
# build the right way
rowdata <- data.frame(x=1:5, row.names=letters[1:5])
@mikelove
mikelove / no_slot_name_of_name_elementMetadata.R
Created November 1, 2018 23:09
no slot name of name elementMetadata"
# load the SummarizedExperiment object but don't load SummarizedExperiment
rowdata <- attr(se,"rowData")
save(rowdata, file="rowdata.rda")
#coldata <- attr(se,"colData")
#save(coldata, file="coldata.rda")
counts <- get("data",attr(attr(se,"assays"),".xData"))$counts
save(counts, file="counts.rda")
# restart R
load("rowdata.rda")