Skip to content

Instantly share code, notes, and snippets.

View rmflight's full-sized avatar

Robert M Flight rmflight

View GitHub Profile
@rmflight
rmflight / example_output.txt
Created September 21, 2016 17:09
Running mixed model ANOVA
> anova_data <- structure(list(y = c(-72.8380122783358, -42.0699052900013, -13.2570336146187,
+ 35.5231083258988, - .... [TRUNCATED]
> # data set:
> #
> # two patients, P1 and P2
> # each patient has samples from two diseases, D1 and D2
> # each of the samples from each patient in e .... [TRUNCATED]
, , patient = P1
{
"mzML": {
"schemaLocation": "http://psi.hupo.org/ms/mzml http://psidev.info/files/ms/mzML/xsd/mzML1.1.0.xsd",
"id": "exampleData",
"version": "1.1.0"
},
"cvList": {
"cv": [
{
"id": "MS",
@rmflight
rmflight / output_xpath.txt
Last active June 27, 2016 20:00
testing xpaths
> library(xml2)
> mzml_file <- "test_mzml.mzML"
> doc <- read_xml(mzml_file)
> xml_find_all(doc, "//cvParam")
{xml_nodeset (0)}
> ns <- xml_ns(doc)
@rmflight
rmflight / feather_input.R
Created March 30, 2016 01:18
feather benchmarking
library(devtools)
# install_github("wesm/feather/R")
library(feather)
library(microbenchmark)
set.seed(3-29-16)
rows <- 100000
x <- data.frame(ints = round(runif(rows, -100, 100)), stringsAsFactors = FALSE)
@rmflight
rmflight / code_counting.md
Last active July 24, 2020 00:26
stuff I always need to find

If you want to know how many lines of code are in an Rmd file:

rmarkdown::render("file.Rmd", output_format = "md_document")

cat file.md | grep -c '^ \{4\}'

And then how many lines of code in .R files:

@rmflight
rmflight / input.r
Last active March 24, 2016 19:58
example of why pairwise.complete.obs is useful
# use case is -omics data where some samples have missing data, can
# be coded as NA or 0, but can always set 0 to NA for my use cases
# want the pairwise correlations, where each pairwise comparison
# removes NA in either of the pairs being compared
set.seed(1234)
data_matrix <- matrix(rnorm(200, 0, 1), nrow = 20)
na_locs <- sample(200, 10)
data_matrix[na_locs] <- NA
@rmflight
rmflight / install_r.md
Last active December 12, 2018 18:12
compile R on fedora
  • Download the tarball to a directory on the local hard drive (i.e. in /home)
  • In the following, change RDir with the actual directory you want to install R to.
tar -xzf ****.tgz
./configure --prefix=/mlab/data/software/RDir --enable-R-shlib --with-recommended-packages=no --with-tcltk --with-cairo
make
make install
@rmflight
rmflight / original_doc.Rmd
Created January 8, 2016 02:25
examples of reflowing in Rmd documents
---
title: "test document"
---
# test
this is just some simple test text to show what will happen if we ask rstudio to reflow
the text
```{r and_a_code_block}
@rmflight
rmflight / 2016_365_papers.md
Last active January 7, 2016 17:24
Recording of my thoughts on papers read over course of 2016

2016-01-05 CompGO: an R package for comparing and visualizing Gene Ontology enrichment differences between DNA binding experiments. interesting take on the problem of comparing two experiments at the annotation level, especially for ways to do it without a cutoff. would be cool to try out some of these methods integrated into categoryCompare, especially wondering if we did PCA on the log odds of subgroups of annotations, or if log odds could be used as a weighting to help find sub groups of annotations.

2016-01-06 Transcriptomic Heterogeneity in Cancer as a Consequence of Dysregulation of the Gene-Gene Interaction Network

@rmflight
rmflight / example_recurse.R
Created December 9, 2015 15:59
reproducible example to get number of counts of function runs in semi-recursive
# function where first calls another function, that in turn calls the first,
# but does so in a way that the second is not called again. I want to test
# how many times f1 and f2 get called under different conditions
f1 <- function(use_f2 = FALSE){
if (use_f2) {
f2()
}
}