Skip to content

Instantly share code, notes, and snippets.

@nachocab
nachocab / new_mac.txt
Last active April 30, 2018 15:30
New mac checklist
## General
### System preferences
# change date and regional settings
language & region | region | spain
date & time | clock | show date
# change trackpad
point & click
enable tap to click
change secondary click to bottom right corner
disable look up
@nachocab
nachocab / treccani.js
Last active January 10, 2018 13:27
Treccani
// Custom JavaScript for Websites Chrome Extension Script for
// the italian dictionary www.treccani.it
// Author: Nacho - NachoTime Spanish
// URL: itsnachotime.com
// License: MIT
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = `
.accezione + .sottoaccezione hr {
@nachocab
nachocab / custom_glosbe.js
Created December 17, 2017 18:17
Customized Glosbe Dictionary - NachoTime Spanish
// Author: Nacho - NachoTime Spanish
// URL: bit.ly/nachotime_vocab
// License: MIT
function newLink(opts) {
let link = document.createElement('a');
link.href = opts.href;
link.innerHTML = opts.content;
link.target = opts.newTab ? '_blank' : '';
link.style = opts.style;
get_sparse_pca <- function(gbm, n_pcs = 10, fastpath = FALSE) {
x <- as.matrix(t(Biobase::exprs(gbm)))
mu <- colMeans(x)
s <- apply(x, 2, sd, na.rm = TRUE)
s[s == 0] <- min(s[s > 0])
svd_res <- irlba::irlba(x, nv = n_pcs, center = mu, scale = s, fastpath = fastpath)
n <- dim(x)[1]
variance_sum <- sum(apply(x, 2, var, na.rm = TRUE)/(s^2))
var_pcs <- svd_res$d^2/(n - 1)/variance_sum
pca_with_outliers <- list(
const stampit = require('stampit')
Grade = stampit({
init(percentage) {
this.percentage = percentage
this.grades = [
{letter: 'A', minimumPercentage: 0.9, passing: true},
{letter: 'B', minimumPercentage: 0.8, passing: true},
{letter: 'C', minimumPercentage: 0.7, passing: true},
{letter: 'D', minimumPercentage: 0.6, passing: true},
El director del periódico de La Razón, Francisco Marhuenda, ha sido nombrado comisario honorario de la Policía Nacional por decisión del ministro del Interior en funciones, Jorge Fernández Díaz, han informado a eldiario.es fuentes policiales. El reconocimiento al periodista se produce a punto de cumplirse cuatro meses del Gobierno en funciones y cuando unas nuevas elecciones generales se avistan para el próximo mes de junio.
La Ley Orgánica 9/2015, de Régimen de Personal de la Policía Nacional, establece en su artículo 86.2 que “la distinción de miembro honorario de la Policía Nacional podrá otorgarse a aquellas personas que, no habiendo pertenecido al citado Cuerpo, se hubieran distinguido por los merecimientos contraídos en virtud de la labor realizada a favor del mismo”.
El expediente en el que se recogen los méritos para recibir la distinción es interno y no se hace público, por lo que resulta imposible conocer qué actuaciones ha protagonizado el agraciado para recibirla. La semana pasada, la Audiencia
@nachocab
nachocab / immgen.tsv
Last active October 17, 2023 15:49
Human-readable version of IMMGEN annotation codes
activated_T_cells T.8Nve.Sp.OT1 spleen OT1 tg Naïve CD8 OT-I tg 6W spleen transfer of 5x10^3 OTI cells Listeria.OVA 5x10^3 cfu
activated_T_cells T.8Eff.Sp.OT1.d6.LisOva spleen OT1 tg effectors CD8 day 6 Listeria.OVA 4- 8+ 45.1+ OT-I tg > B6.CD45.2 6W spleen transfer of 5x10^3 OTI cells Listeria.OVA 5x10^3 cfu
activated_T_cells T.8Eff.Sp.OT1.d8.LisOva spleen OT1 tg effectors CD8 day 8 Listeria.OVA 4- 8+ 45.1+ OT-I tg > B6.CD45.2 6W spleen transfer of 5x10^3 OTI cells Listeria.OVA 5x10^3 cfu
activated_T_cells T.8Eff.Sp.OT1.d10.LisOva spleen OT1 tg effectors CD8 day 10 Listeria.OVA 4- 8+ 45.1+ OT-I tg > B6.CD45.2 6W spleen transfer of 5x10^3 OTI cells Listeria.OVA 5x10^3 cfu
activated_T_cells T.8Eff.Sp.OT1.d15.LisOva spleen OT1 tg effectors CD8 day 15 Listeria.OVA 4- 8+ 45.1+ OT-I tg > B6.CD45.2 6W spleen transfer of 5x10^3 OTI cells Listeria.OVA 5x10^3 cfu
activated_T_cells T.8Mem.Sp.OT1.d45.LisOva spleen OT1 tg Memory CD8 day 45 Listeria.OVA 4- 8+ 45.1+ OT-I tg
@nachocab
nachocab / gene_list.r
Last active October 8, 2015 17:26
Using yaml to deal with gene sets in R
install.packages("yaml")
# change path to your favorite local directory
gene_list <- function(filename, format = "yaml", path = "/Users/nacho/gene_info/gene_sets"){
path <- file.path(path, filename)
if (format == "yaml"){
raw_genes <- yaml::yaml.load_file(path)
# TODO: run through the nested names in genes and check that
# there are no "." or ":", give warning or replace with "_"
unlisted_genes <- unlist(raw_genes)
my_factor <- factor(c("a", "b", "c", "b", "c"), levels = c("c", "b", "a"))
model.matrix(~my_factor) # smyth's way
m <- model.matrix(~ 0 + my_factor) # my way
colnames(m) <- levels(my_factor)
makeContrasts(average_levels = (a + b +c)/3,
b_vs_a = b - a, levels = m)
targets <- read.table("targets.txt", header = TRUE)
counts <- read.delim("counts.txt", row.names = "gene_id")
counts <- counts[, targets$sample_name] # important, the ordering of the columns in the counts file must match the sample_name in the targets file
group <- factor(targets$virus_dpi, levels = unique(targets$virus_dpi))
library(edgeR)
y <- DGEList(counts = counts, group = group)
y <- calcNormFactors(y)
design <- model.matrix( ~ 0 + group, data = y$samples)