Skip to content

Instantly share code, notes, and snippets.

View sahirbhatnagar's full-sized avatar

Sahir Bhatnagar sahirbhatnagar

View GitHub Profile
---
title: "Central Limit Theorem In Action"
author: "by Sahir Bhatnagar"
date: "`r Sys.Date()`"
output:
html_document:
toc: true
toc_float: true
number_sections: true
toc_depth: 4
@sahirbhatnagar
sahirbhatnagar / leuk
Last active January 26, 2017 19:21
Survival Times and White Blood Counts for Leukaemia Patients
time status AG wbc
65 1 1 2.3
140 0 1 0.75
100 1 1 4.3
134 1 1 2.6
16 1 1 6
106 0 1 10.5
121 1 1 10
4 1 1 17
39 1 1 5.4
This file has been truncated, but you can view the full file.
0.2 5000 0.2 400 corr diffcorr 0.6 1 0.1 1 FALSE TRUE euclidean hclust dynamic average 10 10 200 500 0.610920834184329 0.781614248964493 0.547095921066016 759 0.349301397205589 0.129777777777778 0.818036392721456 0.870222222222222 NaN 0.650698602794411 NaN 0.599725534871895 0.774419482497628 0.53768690875801 759 0.349301397205589 0.129777777777778 0.818036392721456 0.870222222222222 NaN 0.650698602794411 NaN 0.297619047619048 0.279100529100529 37.0247504316846 6.08479666313383 0.504017902553148 10 0.00199600798403194 0.002 0.898220355928814 0.998 NaN 0.998003992015968 NaN 0.0320801431473176 0.738996638359458 0.859649136775846 0.596378801749568 2197 0.499001996007984 0.432666666666667 0.560487902419516 0.567333333333333 NaN 0.500998003992016 NaN 0.476976105282242 0.690634567106398 0.546231309124199 757 0.349301397205589 0.129333333333333 0.818436312737453 0.870666666666667 NaN 0.650698602794411 NaN 0.2636860670194 0.205108225108225
0.2 5000 0.2 400 corr diffcorr 0.6 1 0.1 1 FALSE TRUE euclidean hclust dynamic
rho
p
SNR
n
cluster_distance
Ecluster_distance
rhoOther
betaMean
alphaMean
betaE
### Boxplot of {{k}} by number of cylinders
```{r boxplot-by-cyl-{{j}}, eval=TRUE}
ggplot(mtcars,
aes(x = cyl, y = {{j}},
fill = cyl)) +
geom_boxplot() +
theme_bw() +
theme(legend.position = "bottom") +
---
title: "`mapply` and `rmarkdown` for exploratory analysis"
output:
html_document:
fig_height: 5
fig_width: 7
toc: true
toc_float: true
toc_depth: 4
---
library(pwr) # for power calcs
library(dplyr) # for data manipulation
library(tidyr) # for data manipulation
library(ggplot2) # for plotting power curves
# Generate power calculations
ptab <- cbind(NULL, NULL)
for (i in seq(0,1, length.out = 200)){
pwrt1 <- pwr.t2n.test(n1 = 28, n2 = 1406,
structure(list(lambda.beta = c(16.5096521265724, 3.55689672618463,
0.7663101695753, 0.165096521265724, 0.0355689672618463, 0.007663101695753,
0.00165096521265724, 0.000355689672618463, 0.0000766310169575301,
0.0000165096521265724, 16.5096521265724, 3.55689672618463, 0.7663101695753,
0.165096521265724, 0.0355689672618463, 0.007663101695753, 0.00165096521265724,
0.000355689672618463, 0.0000766310169575301, 0.0000165096521265724,
16.5096521265724, 3.55689672618463, 0.7663101695753, 0.165096521265724,
0.0355689672618463, 0.007663101695753, 0.00165096521265724, 16.5096521265724,
3.55689672618463, 0.7663101695753, 0.165096521265724, 0.0355689672618463,
0.007663101695753, 0.00165096521265724, 0.000355689672618463,
@sahirbhatnagar
sahirbhatnagar / methyl_annotate.R
Created March 2, 2015 17:59
Annotating Methylation Probes
methyl.annotate <- function(file, thresholdp=1e-3, thresholdq=1e-1, tissue){
DT <- fread(file)
setnames(DT, c("V1","V2","V3","V4","V5"), c("probe","pvalue","z","sd","effect"))
# use this to get CHR and BP, then merge with betareg results
probe.info <- hm450[DT[["probe"]]]
f <- data.table::data.table(probe=names(probe.info),CHR=as.data.frame(probe.info@seqnames)$value,
BP=as.numeric(probe.info@elementMetadata$probeStart))
data.table::setkey(f,probe)