Skip to content

Instantly share code, notes, and snippets.

View klprint's full-sized avatar

Kevin klprint

View GitHub Profile
@klprint
klprint / app.R
Last active October 6, 2021 20:19
Bundestagswahl 2021 Wahlkreise: Ergebnisse und Strukturdaten
library(shiny)
library(tidyverse)
if(!require(plotly)){
install.packages("plotly")
}
if(!require(viridis)){
install.packages("viridis")
}
@klprint
klprint / hum3d.html
Last active November 11, 2020 07:32
3dembs
This file has been truncated, but you can view the full file.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style>body{background-color:white;}</style>
<script>(function() {
// If window.HTMLWidgets is already defined, then use it; otherwise create a
// new object. This allows preceding code to set options that affect the
// initialization process (though none currently exist).
window.HTMLWidgets = window.HTMLWidgets || {};
library(hdf5r)
library(Matrix)
source("https://gist.githubusercontent.com/klprint/1ab4468eb3c54abcf0422dec6223b8fc/raw/b4cc33f5b4da25bcc2e678cf46b692fe67605460/single_cell_functions.R")
library(SingleCellExperiment)
library(tidyverse)
library(liger)
sce.raw.pca <- function(sce, k = 100){
umi <- assay(sce, "umi")
library(hdf5r)
library(Matrix)
source("https://gist.githubusercontent.com/klprint/1ab4468eb3c54abcf0422dec6223b8fc/raw/b4cc33f5b4da25bcc2e678cf46b692fe67605460/single_cell_functions.R")
library(SingleCellExperiment)
library(tidyverse)
sce.raw.pca <- function(sce, k = 100){
umi <- assay(sce, "umi")
cat("Getting informative genes\n")

Keybase proof

I hereby claim:

  • I am klprint on github.
  • I am subfish (https://keybase.io/subfish) on keybase.
  • I have a public key ASB7mGynrtArFJP7l3XxhFVDHk4Yxr5JqkMl_9mFEjPVMwo

To claim this, I am signing this object:

@klprint
klprint / single_cell_functions.R
Last active January 30, 2020 12:45
Widely used single cell functions in R
# Taken from Simon
# compute variances across column or rows for column-sparse matrices
library(Matrix)
colVars_spm <- function( spm ) {
stopifnot( is( spm, "dgCMatrix" ) )
ans <- sapply( seq.int(spm@Dim[2]), function(j) {
mean <- sum( spm@x[ (spm@p[j]+1):spm@p[j+1] ] ) / spm@Dim[1]
sum( ( spm@x[ (spm@p[j]+1):spm@p[j+1] ] - mean )^2 ) +
mean^2 * ( spm@Dim[1] - ( spm@p[j+1] - spm@p[j] ) ) } ) / ( spm@Dim[1] - 1 )
names(ans) <- spm@Dimnames[[2]]
library(rlc)
library(matrixStats)
library(biomaRt)
library(Matrix)
library(umap)
#sobj <- readRDS("make_analysis_out/SN010_E115/SN010_E115_normalized.rds")
makeENSMEBLlink <- function(geneID){
sprintf(
"<a href='http://www.ensembl.org/Mus_musculus/Gene/Summary?db=core;g=%s' target='_blank'>%s</a>",
@klprint
klprint / parse_10x_output.sh
Created June 4, 2018 11:53
Parse a 10x chromium sparse matrix output into a single file, inserting the ENSEMBL gene ID and the cell barcode
#!/bin/bash
# The following script parses the 10x chromoium sparse matrix.
# It replaces the First column with the ENSEMBL gene ID and the second,
# if needed, with the cell barcode (just uncomment the second awk script).
# It needs the three 10x chromium outputs as follows:
# 1. genes.tsv
# 2. matrix.mtx
# 3. barcodes.tsv
@klprint
klprint / ChangeChmod.txt
Created August 1, 2016 08:18
Change chmod for folder & all subfolders
# Sets chmod 755 for folder and all subfolders
find /opt/lampp/htdocs -type d -exec chmod 755 {} \;
# Sets chmod 655 for all files in this folder & subfolder
find /opt/lampp/htdocs -type f -exec chmod 644 {} \;
# Analyse data using a sliding window
slideFunct <- function(data, window, step){
total <- length(data)
spots <- seq(from=1, to=(total-window), by=step)
result <- vector(length = length(spots))
for(i in 1:length(spots)){
result[i] <- median(data[spots[i]:(spots[i]+window)])
}
return(result)
}