Skip to content

Instantly share code, notes, and snippets.

@arraytools
arraytools / smart_pny1t.txt
Last active August 15, 2023 01:24
smart from a brand new 1T PNY SSD
$ sudo smartctl -a /dev/sdb
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.19.0-46-generic] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Device Model: PNY CS900 1TB SSD
Serial Number: PNY231123031701048A6
LU WWN Device Id: 5 f8db4c 2311048a6
Firmware Version: CS900LA5
User Capacity: 1,000,204,886,016 bytes [1.00 TB]
@arraytools
arraytools / vibrant_mine.rstheme
Created May 29, 2023 15:30
Vibrant Ink SB 2 theme for RStudio
/* rs-theme-name: Vibrant Ink SB 2 */
/* rs-theme-is-dark: TRUE */
.ace_gutter {
background: #1a1a1a;
color: #BEBEBE
}
.ace_print-margin {
width: 1px;
background: #444;
}
@arraytools
arraytools / renv_restore.log
Created January 23, 2023 03:03
Output log from calling renv::restore() on a new computer. This is testing on Ubuntu 22.04, renv 0.16.0.
> renv::restore()
Welcome to renv!
It looks like this is your first time using renv. This is a one-time message,
briefly describing some of renv's functionality.
renv maintains a local cache of data on the filesystem, located at:
- "~/.cache/R/renv"
@arraytools
arraytools / docker-compose.yml
Last active October 10, 2022 13:36
Grafana using docker
version: '3.3'
services:
node-exporter:
image: quay.io/prometheus/node-exporter:latest
container_name: node_exporter
command:
- '--path.rootfs=/host'
network_mode: host
pid: host
restart: unless-stopped
@arraytools
arraytools / shiny-examples.Rmd
Created September 6, 2022 13:17
create a table of URL links to shiny examples (https://github.com/rstudio/shiny-examples)
---
title: " "
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(dplyr)
library(knitr)
library(kableExtra)
KRT19 E
AGR2 E
RAB25 E
CDH1 E
ERBB3 E
FXYD3 E
SLC44A4 E
S100P E
SCNN1A E
GALNT3 E
@arraytools
arraytools / EMgenes.R
Last active February 14, 2023 01:51
Epithelial and mesenchymal gene signatures from Tan et al. 2014 . ‘Table S1B. Generic EMT signature for cell line’ & 'Table S1A. Generic EMT signature for tumour'. See also https://bioconductor.org/packages/release/bioc/vignettes/singscore/inst/doc/singscore.html#22_Sample_scoring_with_a_reduced_number_of_measurements
x <- readxl::read_excel("~/Downloads/EMset.xlsx")
x %>% drop_na() %>% write.table("~/Downloads/EMset.txt", quote=F, row.names = F)
x2 <- read.table("~/Downloads/EMset.txt")
dim(x2) # 218 x 2
epi <- x2[1:170, 2]
mes <- x2[171:218, 2]
x3 <- data.frame(symbol=x2[,2], epimes=c(rep("epi", 170), rep("mes", 48)))
x3[, 1] <- gsub(substr(x3[1,1], 1, 1), "", x3[,1]) # rm "white space'?
write.table(x3, file="~/Downloads/EMgenes_cellline.txt", quote=F, row.names = F, sep="\t")
@arraytools
arraytools / interObj.R
Created January 26, 2022 17:32
Demonstration of interaction model
df <-
structure(list(muc6 = c(0.65991920232772827, 12.234284400939941,
7.5393352508544922, 13.921844482421875, 4.8508410453796387, 0,
6.7801151275634766, 5.5127406120300293, 1.030299186706543, 3.5845346450805664,
0.98191821575164795, 0, 0, 1.052558422088623, 0, 0, 2.5294754505157471,
0.59700602293014526, 0, 0, 7.0485143661499023, 0, 0, 0, 1.1008850336074829,
5.777961254119873, 6.1289887428283691, 0, 4.9814505577087402,
0, 5.4703717231750488, 8.0720577239990234, 0), tumortype = c("Carcinoma",
"sarcoma", "Carcinoma", "Carcinoma", "sarcoma", "sarcoma", "Carcinoma",
"Carcinoma", "sarcoma", "sarcoma", "Carcinoma", "Carcinoma",
@arraytools
arraytools / glmnet_surv_code
Last active December 26, 2020 16:25
Survival data used for glmnet. n=78, p=101.
library(glmnet)
x <- dget(url("https://gist.githubusercontent.com/arraytools/238e812555d69cb0213adaf99353c25f/raw/911bd4c6810fff6483521808cd1dfa1833891eb7/glmnet_surv_x"))
y <- dget(url("https://gist.githubusercontent.com/arraytools/238e812555d69cb0213adaf99353c25f/raw/911bd4c6810fff6483521808cd1dfa1833891eb7/glmnet_surv_y"))
lambda <- dget(url("https://gist.githubusercontent.com/arraytools/238e812555d69cb0213adaf99353c25f/raw/911bd4c6810fff6483521808cd1dfa1833891eb7/glmnet_surv_lambda"))
cvfit <- cv.glmnet(x, y, family = "cox", nfolds=10)
fit <- glmnet(x, y, family = "cox", lambda = lambda)
coef.cv <- coef(cvfit, s = lambda)
coef.fit <- coef(fit)
length(coef.cv[coef.cv != 0]) # 31
@arraytools
arraytools / embed.c
Created November 24, 2020 23:35
An example from Bioconductor workshop
#include <Rembedded.h>
#include <Rdefines.h>
static void doSplinesExample();
int
main(int argc, char *argv[])
{
Rf_initEmbeddedR(argc, argv);
doSplinesExample();
Rf_endEmbeddedR(0);