Skip to content

Instantly share code, notes, and snippets.

View simon-anders's full-sized avatar

Simon Anders simon-anders

  • University of Heidelberg
  • Heidelberg, Germany
View GitHub Profile
@simon-anders
simon-anders / pca.R
Created April 28, 2021 14:24
Imputation via PCA
library( irlba )
m <- 10000 # nbr of features (rows)
n <- 5000 # nbr of cells (colums)
r <- 5 # nbr of latent components
## The true latent values
# True importance of latent factors
true_importance <- c( 1, .8, .4, .2, .1 )
## Beispiel für Plot-Größe
Tidyverse laden:
```{r}
library( tidyverse )
```
Wir benutzen `mtcars`, eine Standard-Beispiel-Tabelle von R mit technischen Daten
für (recht alte) Autos:
import gzip, random
# Load FASTQ file for Chromosome 10 from GRCm38
with gzip.open("data/Mus_musculus.GRCm38.dna.chromosome.10.fa.gz") as f:
firstline = f.readline()
assert firstline.startswith(b'>')
chrom_seq = b"".join(l.rstrip() for l in f)
# This here is the file from papagei:mnt/raid/scnmt_data/CpG_filtered
cpg = scipy.sparse.load_npz( "data/CpG_10.npz" ).tocoo()
# Make example data
n <- 15
x <- runif( n, 0, 10 )
y <- sin(x) + rnorm( n, sd=.1 )
# Make grid to plot smooth curves
xg <- seq( 0, 10, length.out=1000 )
# Determine knot positions: