Skip to content

Instantly share code, notes, and snippets.

View dmbates's full-sized avatar

Douglas Bates dmbates

View GitHub Profile
@dmbates
dmbates / warning.ipynb
Created April 26, 2024 14:28
Use of `warning: false` with QuartoNotebookRunner
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dmbates
dmbates / RCall_IJulia_ggplot2.qmd
Last active July 2, 2022 11:42
Using ggplot2 in IJulia notebook through RCall
---
jupyter: julia-1.7
---
```{julia}
using RCall
```
```{julia}
RCall.ijulia_setdevice(MIME("image/svg+xml"))
@dmbates
dmbates / benchmark.jl
Created June 4, 2022 13:33
Code for benchmarking sort!(unique!(df)) versus sort!(df) on a real-world example
using CSV, DataFrames, Downloads, Tar
datadir = "biofast-data-v1"
tarball = "$datadir.tar.gz"
if !isfile(tarball)
dataurl = joinpath(
"https://github.com/lh3/biofast/releases/download",
datadir,
tarball,
)
@dmbates
dmbates / Issue611.ipynb
Created May 3, 2022 18:04
Notebook related to MixedModels.jl issue 611
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dmbates
dmbates / dyestuff.Rnd
Created April 2, 2014 17:44
MathJax coding for \mathcal does not show up properly in the RStudio HTML previewer.
---
title: JAGS and lme4
author: Douglas Bates
date: March 28, 2014
output:
html_document:
toc: yes
highlight: tango
fig_width: 7
fig_height: 5.5
@dmbates
dmbates / permsums.ipynb
Last active April 20, 2021 17:14
Permutation tests in Julia
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dmbates
dmbates / intro.md
Created March 3, 2014 23:30
Environment-based lme4

Background

The current version of the (lme4)[https://github.com/lme4/lme4] package for (R)[http://www.r-project.org) is based on a rather questionable practice of storing external pointers from C++ objects in an R reference class object. The idea was that when the reference class object was created the corresponding C++ class instance would be created. All changes to this object would be made through the external pointer in the C++ code.

This is risky because any changes to the R objects in the reference class could cause changes in the location of its values, after which all bets are off because the R object and the C++ object are referring to different memory locations.

It turns out that this does happen in the development version of R, which will become R-3.1.0, if the LAZY_DUPLICATE_OK flag is set. The symptom is that deepcopy methods are not copying and I suspect this is because the lazy duplication doesn't duplicate before the external pointer is constructed. We were living outsid

@dmbates
dmbates / Problem104.ipynb
Created October 3, 2013 19:54
Project Euler problem 104 in Julia.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dmbates
dmbates / casestudy.md
Last active December 17, 2015 22:19
Handling Genome-Wide Association study data in Julia

Objectives

The dimensions of data on DNA variation such as single nucleotide polymorphisms or SNPs can be very large, involving thousands or millions of SNPs, measured on potentially thousands of individuals. Typical genotyping platforms may examine from 50K(K=thousand) to 2.5M (M= millions) SNPs. Some platforms could be even denser. There are 2 nucleotides (A, C, G or T) at each position (one on each chromosome). If the genotyping read is not sufficiently good, a missing value could be recorded in one or both chromosomes for that position/SNP. A frequently used re-codification of the nocleotide data is to replace the characters (i.e. alleles) by the count of the allele with the lower frequency in the sample, or according to a pre-specified allele as determined in the genotyping platform and software. Thus, instead of storing a pair of nucleotides (e.g., AA, AG, GG), researchers store the individual’s genotype as either 0,1,2, or NA. In thi

@dmbates
dmbates / gist:5303570
Last active December 15, 2015 18:28
Formula, ModelFrame and ModelMatrix types

Formula, ModelFrame and ModelMatrix types

In R, the functions for fitting statistical models based on a linear predictor usually allow for a formula/data specification of the model. The data part is a data.frame object in R. In Julia the corresponding type is a DataFrame as implemented in the DataFrames package.

A formula object in R is an expression whose top-level operator is a unary or binary tilde, ~. The interpretation of many operators, including +, *, ^, \ and : are overridden in the formula language. See the result of

?formula

in R for the details.