This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import pysam | |
| import numba | |
| @numba.njit | |
| def _check_cigar_pos(pos, cigar): | |
| if pos > cigar.shape[0]: | |
| raise ValueError("Invalid CIGAR string (1)") | |
| @numba.njit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library( tidyverse ) | |
| read_tsv("~/tmp/truth_gene_expression_protein_coding_summed_by_tissue_negative_strand.csv") %>% | |
| mutate( gene = coalesce( `Gene name`, `Gene stable ID` ) ) %>% | |
| column_to_rownames("gene") %>% select( -(1:4) ) %>% as.matrix -> true_expr | |
| read_tsv("~/tmp/predicted_gene_expression_protein_coding_summed_by_tissue_negative_strand.csv") %>% | |
| mutate( gene = coalesce( `Gene name`, `Gene stable ID` ) ) %>% | |
| column_to_rownames("gene") %>% select( -(1:4) ) %>% as.matrix -> pred_expr | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::fs::File; | |
| use std::io::{BufReader,BufRead,self,Write}; | |
| use std::error::Error; | |
| use std::collections::{HashMap,VecDeque,HashSet}; | |
| use std::env; | |
| #[derive(Debug)] | |
| struct Interval { | |
| chrom: i32, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Load "anndata" Python package via reticulate | |
| # so that we can read the h5ad file | |
| library( reticulate ) | |
| use_virtualenv("~/pyenvs/main/") | |
| anndata <- import("anndata") | |
| # Load the h5ad file from ZebraHub | |
| # https://figshare.com/ndownloader/files/36736206 | |
| ad <- anndata$read_h5ad("zf_atlas_full_v1_release.h5ad") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library( tidyverse ) | |
| library( haven ) | |
| left_join( | |
| read_xpt("~/Downloads/DEMO_J.xpt"), | |
| read_xpt("~/Downloads/BMX_J.xpt"), | |
| by="SEQN", relationship="one-to-one" ) %>% | |
| select( subjectId=SEQN, gender_code=RIAGENDR, | |
| age=RIDAGEYR, ethnicity_code=RIDRETH3, height=BMXHT ) -> nhanes0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| format: | |
| html: | |
| embed-resources: true | |
| --- | |
| # Density estimation for single-cell gene expression with MCMC | |
| Simon Anders, 2024-10-23 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library( rstan ) | |
| options(mc.cores=6) | |
| n <- 1000 | |
| s <- round( 10^rnorm( n, 3, .5 ) ) | |
| fracs <- 10^ifelse( runif(n)<.7, rnorm( n, -3.3, .4 ), rnorm( n, -1.7, .2 ) ) | |
| k <- rpois( n, fracs*s ) | |
| model <- stan_model( model_code=" | |
| data { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## 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: |
NewerOlder