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(Biostrings) | |
dna <- readDNAStringSet("test_sequences.fasta") | |
ids <- names(dna) | |
library(tidyverse) | |
library(plyranges) | |
dat <- data.frame(ids) | |
into <- c("seqnames","start","end","pos","relpos", | |
"ref","alt","allele","rsid","RE") | |
dat <- dat %>% | |
separate(ids, sep="_", into=into, convert=TRUE) |
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
# https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSM2095218 | |
#url <- "ftp://ftp.ncbi.nlm.nih.gov/geo/samples/GSM2095nnn/GSM2095218/suppl/GSM2095218%5FDEX%5F3hr%5FGR%5FChIPseq%2ERep1%5Fpeaks%2Ebed%2Egz" | |
#download.file(url, destfile="GSM2095218_DEX_3hr_GR_ChIPseq.Rep1_peaks.bed.gz") | |
library(plyranges) | |
x <- read_bed("GSM2095218_DEX_3hr_GR_ChIPseq.Rep1_peaks.bed.gz") | |
genome(x) <- "hg19" | |
options(Biostrings.coloring=FALSE) |
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
x <- read.csv("GSE91061_BMS038109Sample.hg19KnownGene.raw.csv", row.names=1) | |
condition <- factor(sub(".+_(.+)_.+", "\\1", colnames(x))) | |
library(DESeq2) | |
dds <- DESeqDataSetFromMatrix(x, colData=data.frame(condition), ~condition) | |
vsd <- vst(dds, blind=FALSE) | |
plotPCA(vsd) | |
rv <- rowVars(assay(vsd)) | |
pc <- prcomp(t(assay(vsd)[head(order(-rv),1000),])) |
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(SingleCellExperiment) | |
sce <- readRDS("sce_metaCells.rds") | |
dim(sce) | |
assayNames(sce) | |
a1 <- as.matrix( round(assay(sce, "dmel_counts")) ) | |
a2 <- as.matrix( round(assay(sce, "counts") - a1) ) | |
a1[is.na(a1)] <- 0 | |
a2[is.na(a2)] <- 0 |
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
# Variants and peaks coverage | |
# Michael Love | |
# March 11, 2022 | |
library(readr) | |
library(dplyr) | |
library(tidyr) | |
library(plyranges) | |
# read_narrowpeaks -> just works |
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
# Gviz library uses TxDb to make gene models | |
# this is convenient bc we can build TxDb from any source | |
library(Gviz) | |
library(TxDb.Dmelanogaster.UCSC.dm6.ensGene) | |
txdb <- TxDb.Dmelanogaster.UCSC.dm6.ensGene | |
# load our TSS-summarized data, now has GRanges on rows | |
suppressPackageStartupMessages(library(SummarizedExperiment)) | |
load("se_tss.rda") |
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(SingleCellExperiment) | |
sce <- readRDS("sce.rds") | |
labels <- readRDS("cellLabels.rds") | |
sce <- sce[,names(labels)] | |
colLabels(sce) <- labels | |
table(labels) | |
assayNames(sce) | |
total_count <- rowSums(assay(sce)) |
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
snp_hg38 | rsid | refAllele | altAllele | lfcASCA | lfcQTL | lfcEQTL | |
---|---|---|---|---|---|---|---|
chr2:208557023:C:G | rs1036014 | C | G | 0.679909666011761 | 0.2499407877 | 0.2194325508 | |
chr4:9924989:T:C | rs10939614 | T | C | -2.21500762508123 | -0.355952769 | -0.2118339332 | |
chr7:138187033:C:T | rs17603855 | C | T | -1.73696246880911 | -0.4433277822 | -0.4808215973 | |
chr7:139495451:C:G | rs2530731 | C | G | -1.77729493517346 | -0.6283644361 | -0.3881908065 | |
chr11:86515916:G:C | rs2125358 | G | C | 1.36463250810021 | 0.4783681025 | 0.4154173162 | |
chr14:22848616:A:G | rs17882077 | A | G | -1.34268551797455 | -0.2681226196 | -0.2210454793 | |
chr18:25019730:G:A | rs10502466 | G | A | 0.716207533070227 | 0.2821604048 | 0.2185292588 | |
chr21:43270976:A:G | rs2838227 | A | G | 0.8181622133663 | 0.304950793 | 0.4107778657 |
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
# Michael Love | |
# Dec 25 2021 | |
# make some sim data | |
a <- rnorm(10) | |
b <- rnorm(10) | |
dat_x <- rbind(a+rnorm(10,0,2), | |
a+rnorm(10,0,.5), | |
rnorm(10), | |
b+rnorm(10)) |
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
# Michael Love | |
# Dec 12 2021 | |
# read in data -- plyranges is dplyr for GRanges | |
# I've been moving towards using this in my lab | |
library(dplyr) | |
library(plyranges) | |
a <- read_bed("featuresA.hg19.bed") | |
b <- read_bed("featuresB.hg19.bed") | |
a <- a %>% mutate(id=seq_along(a)) # ID for regions in 'a' |