Skip to content

Instantly share code, notes, and snippets.

View DannyArends's full-sized avatar

Danny Arends DannyArends

View GitHub Profile
@DannyArends
DannyArends / PCA.R
Created July 10, 2024 19:01
Code for the YouTube lecture "Principal Component Analysis from Scratch" (https://www.youtube.com/live/y9zS7Xm0iEU)
# Unit-Variance Scaling or Autoscaling
autoscale <- function(X) {
return(apply(X,2, function(x){ (x- mean(x)) / sd(x) }))
}
# Compute the covariance matrix
covariance <- function(X) {
cM <- matrix(NA, ncol(X), ncol(X), dimnames = list(colnames(X), colnames(X)))
for(x in colnames(X)) {
@DannyArends
DannyArends / Enrichment.R
Last active June 29, 2024 09:31
Code for the YouTube lecture "Enrichment Analysis from Scratch" (https://www.youtube.com/live/MJ4A5fmgWhg)
#
# Code for the lecture on "Gene Ontology from Scratch"
# copyright (c) 2020-2024 Danny Arends
#
# This program is free software; you can redistribute it and/or modify it under the terms of
# the GNU General Public License,version 3, as published by the Free Software Foundation.
# This program is distributed in the hope that it will be useful, but without any warranty;
# without even the implied warranty of merchantability or fitness for a particular purpose.
#
# For more details see: www.gnu.org/licenses/gpl-3.0.en.html
# Author : Danny Arends
# Purpose : create an MRI table from the format provided by our MRI reader
months <- rbind(c("Jan",31),c("Feb",28),c("Mar",31),c("Apr",30),c("May",31),c("Jun",30),
c("Jul",31),c("Aug",31),c("Sep",30),c("Oct",31),c("Nov",30),c("Dec",31))
createMRItable <- function(MRIdata, description){
dates <- strsplit(unlist(lapply(strsplit(as.character(MRIdata[,"TimeDateDura"]),";"),"[",1))," ") # Get the malformed dates
MRIdata[,"TimeDateDura"] <- unlist(lapply(dates, function(x){ # Transform to DD/MM/YY
#
# Call expression from aligned SRA reads
# copyright (c) 2022 - Danny Arends
#
library("GenomicAlignments")
library("GenomicFeatures")
library("Rsamtools")
library("preprocessCore")
library("vioplot")
@DannyArends
DannyArends / 0_installSoftware.sh
Last active December 16, 2024 09:31
Scripts and other things for RNA-Seq
# Add yourself to the sudo group
su -
usermod -aG sudo danny
exit
# Install the virtual box guest additions
cd /media/cdrom0
sudo sh ./VBoxLinuxAdditions.run
# Install R and deps
<!DOCTYPE HTML>
<head>
<title>DannyArendsTwitchOverlayApp</title>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<script src="https://extension-files.twitch.tv/helper/v1/twitch-ext.min.js"></script>
<script src="js/secret.js"></script> <!-- Contains startTwitch function which calls getAppToken with Client-ID and Client-Secret -->
<script>
var audio1 = new Audio('Audio/teleport.mp3');
#
# Download the earth texture from: https://www.solarsystemscope.com/textures/, open in MS Paint, scaled down to 50% size and save as BMP
# Or download it from: https://www.dannyarends.nl/etc/img/2k_earth_daymap.bmp
# JHU CovID19 data from: CSSE at Johns Hopkins University (CSSEGISandData)
# copyright GPL-3 by Danny Arends - Molekulare Zuchtungsbiology - HU Berlin
# Written May, 2020, last modified May, 2020
#
# Change: /path/to/ and set the working dir to the BMP image
setwd("/<path>/<to>/")
@DannyArends
DannyArends / SHA1error_d3js.html
Created September 15, 2015 07:43
SHA1 error when loading d3.min.js from: https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js [Firefox]
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script type="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
</head>
<body>
Open the developer console in firefox to see the error
</body>
</html>
@DannyArends
DannyArends / packages.R
Last active August 29, 2015 14:18
Installation of most R packages I use
# Bioconductor packages
source("http://bioconductor.org/biocLite.R")
biocLite(ask=FALSE)
biocLite(c("preprocessCore", "biomaRt", "affy", "limma", "beadarray", "ggplot2", "impute", "DESeq2", "Rsamtools", "vsn"))
biocLite(c("topGO", "GO.db", "KEGG.db", "MotifDb", "seqLogo", "motifStack"))
biocLite(c("Biostrings", "GenomicAlignments", "GenomicFeatures", "BiocParallel"))
biocLite(c("BSgenome.Mmusculus.UCSC.mm10", "TxDb.Mmusculus.UCSC.mm10.ensGene"))
biocLite(c("gcrma", "lumi", "ShortRead", "cdfpackage", "seqinr", "reshape2", "plyr", "scales"))
# CRAN packages
@DannyArends
DannyArends / gist:d7b3d8182709ac3cf4f5
Created June 18, 2014 13:24
Weird plot, but nice
phi <- 0
while(TRUE){
plot(sin(phi + 1:20), col=c("black","black","red"), cex=3, pch=c("☢","☠","♥"))
Sys.sleep(0.1)
phi = phi +0.3
}