sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
634644cb6ae78aa26aeb09aa7b9831495082c58f139a89eaab73876d372859fa
R
675
21
#' spatial_adjacency_matrix() #' #' Creating spatial-driven adjacency matrix using cell spatial coordinates #' #' @param obj stCCA S3 Object #' #' @return A matrix that describes the adjacency relationships between cells. The entries in the matrix are binary values (0 or 1) that indicate whether cells are adjacent to e...
42d35b27b2e443daaf4372c9d7d395ddac748377b9b945a0121142c999e28c55
R
681
25
library(dplyr) library(Seurat) library("ggplot2") library(monocle3) library(patchwork) library(SeuratWrappers) library(harmony) library(ggplotify) library(rmarkdown) subsets <- readRDS("rObjects/subsets_list.rds") for (i in 1:9){ outName <- names(subsets)[i] cds_subset_cc <- sobjToCds(seuratObj_subset) saveRD...
c54c9128e4776bd708b68c3ae3a843542e2a77952eaf598521ecf4f52dc2626e
R
686
41
# Remove cache if you prefer to recalculate all the alignments # unlink("tmp", recursive=T, force=T) source("01-replication_fork_nn.R") tzNN_prepare_training_data() tzNN_train() tzNN_evaluate() gc() source("02-detect_offtargets.R") detect_offtargets() gc() source("03-detect_rdc.R") detect_rdc() gc() source("04-rdc...
b74089fe00c844ee36fd068cb9aff7ae72819e7cb0a2cf168c71cfe42e84a9fd
R
695
16
spatial_predict = function(model, df, class_ID) { ## predict() in XGBoost uses as many threads as set in `xgb.Booster` (all by default) ## additionally, conversion matrix to `xgb.DMatrix` uses multiple threads too pred = predict(model, as.matrix(df), reshape = TRUE) pred_class = max.col(pred) - 1L prob_class ...
bcef954b2433f7087d2ee75a91d6b72b7155c6d481b37285c6e9d75ee28d113a
R
697
20
### DATA d <- read.table("data.txt", header = T) genes <- read.csv("human_gene_annotation.csv", header = T) rownames(d) <- genes[,2] d <- d[,2:ncol(d)] ### ANNOTATIONS ann <- read.table("human_islet_cell_identity.txt", header = T, sep = "\t", stringsAsFactors = F) rownames(ann) <- ann[,1] rownames(ann) <- gsub(" ", "_...
0093d99732f4ad9fcc2dd51ecd2f9b228c0cd559d31e789eb409605534d737e9
R
719
29
--- title: "GO_Term" output: html_notebook --- ```{r} library(enrichR) ``` ```{r} dbs <- listEnrichrDbs() dbs <- c("GO_Molecular_Function_2018", "GO_Cellular_Component_2018", "GO_Biological_Process_2018") # enriched <- enrichr(module_genes$'0'[1:50], dbs) #input module genes ``` ```{r} E16_proj_DE <- read_csv("/dat...
9a0ac6ba74f97b73e125ba70dcf8c0e2230c065ead2b8a1c7d1e78733dcfb42e
R
744
13
# Figure 3 in situ heatmaps situgenes <- c("Gsg1l", "Sstr2", "Chrna3", "Tfap2b", "Cbfa2t2", "Fbxl7", "Smoc1", "Gsx1", "Prmt8") for (i in situgenes) { compareheatmap(trajectories, trajectorynames, i, span = 0.3) %>% ggsave(file = paste("figures/fig 3/updated_", i, ".png", sep = ""), height = 1, width = 4) } f...
10932e74ba0cd74cb90ed98390cdef33501617329b7298c76f92f9d589239870
R
747
14
#' Pruning data and a tree to a particular subset #' #' Prunes a comparative dataset down to a particular clade #' @param data a vector of tip values for species; should be in the same order as tiplabels in the tree #' @param tree an object of class "phylo". #' @param targetGroup vector listing the tip labels to which ...
45e0058612e57aab974ddef0ce74a862da568c6c989f2c82ea41dd0b56c7ffc5
R
753
22
inputFile = "raw/jointData.txt" outputFile = "results/macrophage_DoRothEA.txt" minNrOfGenes = 5 # Load requeired packages library("dorothea") dorotheaData = read.table('annotation/dorothea.tsv', sep = "\t", header=TRUE) confidenceFilter = is.element(dorotheaData$confidence, c('A', 'B')) dorotheaData = dorotheaData[co...
f8acde480bfa45a9947d39df296bd05e8c92892c6b3ca1637f0a7edf89603a3b
R
761
20
#!/usr/bin/env Rscript # This little script runs the demux comparisons notebook for each library # present in the data folder. Note that the main text will not change, # even though results can vary among libraries, sometimes widely. rmd_template <- "15-demux-comparisons.Rmd" outdir <- file.path("results", "noteboo...
6de18ac5aabe049799f7f3067fb0fe64c9288cd2b88a10ec5e1c7f3418a2abbc
R
765
23
setwd('/work/AnneSophiaHartebrodt#6698/ms-project/') require(rhdf5filters) require(rhdf5) require(Rhdf5lib) renv::activate('/work/AnneSophiaHartebrodt#6698/ms-project/r-single-cell') renv::repair() set.seed(11) require(data.table) require(stringr) atac.de.dir<-file.path('/work/AnneSophiaHartebrodt#6698/ms-project/sub...
a1e0ac13faf10895f0b17ec03cf1f532a74c65bab47e37f6b0d0db4959eaa3ae
R
765
11
library(DiffBind) Control_K27ame3_cluster <- dba(sampleSheet = "Control_K27me3_1-6_7-19.csv",dir=system.file("extra", package="DiffBind")) Control_K27ame3_cluster_count <- dba.count(Control_K27ame3_cluster) Control_K27ame3_cluster_contrast <- dba.contrast(Control_K27ame3_cluster_count,categories = DBA_CONDITION, m...
4c0a86e2a342a425c152e11b83bd2d41d0298658ee54782677fe4a72636fe516
R
772
35
pretty_path_label <- function(pathways, wrap = NULL){ split_path <- str_replace_all(pathways, "_", " ") %>% str_split(" ") split_NA <- function(x){ term <- str_c(x, collapse = " ") %>% str_extract("[A-Z]*[D,R]+NA") term1 <- str_remove(term, "[D,R,T]+NA") %>% str_to_lower() ...
23fedc049312d54d9dac697703c247b55ce26d1d499200dea4972d51cc039873
R
785
20
#' dlpfc #' #' #' The data provided is a list of Data set containing LIBD human dorsolateral pre-frontal cortex (DLPFC) #' and spatial transcriptomics data (sample id 151673) generated with the 10x Genomics Visium platform. #' #' This data is provided as a sample data to understand the package and not a mandatory req...
62f8cdad5d2be6d887e90cee556ec1c3d1be9a299291ee95432c8df65da46629
R
790
25
library(ggplot2) # Sample data data <- data.frame( model = rep(c("DNN", "XGB"), each = 4), metric = rep(c("accuracy", "f1", "precision", "recall"), 2), value = c(0.8945, 0.9326, 0.9358, 0.9294, 0.9049, 0.7519, 0.6556, 0.8815) ) # File path to save the plot file_path <- "mlmodel_metric_compare.png" # Open a PNG...
7c770530f69ea5386ec97f0587d29cf1ca9ac0f7d5bde0d63c2aac7204a5012c
R
794
22
library("ggplot2") data = read.csv("results/variable_importance.csv") data$Feature[2] = "Median 1000 m" data$Feature[3] = "Median 500 m" data$Feature[5] = "St. Dev." data$Feature[9] = "Multi-scale TPI" ggplot(data, aes(x = Gain, y = reorder(Feature, Gain))) + xlab("Information gain") + ylab("Geomorphometric varia...
4ec0c459e37751027f4491c5a08f8c9beaf259f9aa210381f5502e180e169a5e
R
795
17
#' Sample dataset to test UCell installation #' #' A sparse matrix (class "dgCMatrix") of single-cell transcriptomes #' (scRNA-seq) for 30 cells and 20729 genes. #' Single-cell UMI counts were normalized using a standard log-normalization: #' counts for each cell were divided by the total counts for that cell and #' mu...
a3d8c85971800bf8360dbdd730a935c8f84e189e403d62796bb5934618c308aa
R
798
11
# Execute the original authors' inference function and fitted parameter object. # Usage: Rscript generate_miage_references.R /tmp/MiAge-original-mirror /tmp/miage_fixture_input.csv output.csv args <- commandArgs(trailingOnly=TRUE) source(file.path(args[1], 'function_library.r')) load(file.path(args[1], 'site_specific_p...
58e5b8e892461e4df70c475ed58f79941be87a76f0ca93241e43aa6d67b5e64a
R
803
22
### DATA d0 <- read.csv("klein/GSM1599494_ES_d0_main.csv", header = FALSE) d2 <- read.csv("klein/GSM1599497_ES_d2_LIFminus.csv", header = FALSE) d4 <- read.csv("klein/GSM1599498_ES_d4_LIFminus.csv", header = FALSE) d7 <- read.csv("klein/GSM1599499_ES_d7_LIFminus.csv", header = FALSE) d <- cbind(d0, d2[,2:ncol(d2)], d4[...
bcb391be1eef85b293f8982cc77cf15fef0ab1a5cf58e88af6c2e0a708f16b2b
R
809
32
## ---Libraries ------ library(Signac) library(Seurat) library(GenomeInfoDb) library(EnsDb.Hsapiens.v86) library(ggplot2) library(dplyr) library(patchwork) library(rtracklayer) library(cowplot) #library(BSgenome.Hsapiens.UCSC.hg38) library(JASPAR2020) library(TFBSTools) library(patchwork) ##--- Functions -------- howM...
d4e4d3dbd22876b2a6fcce39c78c76e1e029f530b16d1c7a268e6e6877452cfc
R
810
12
# Original-author R execution, independent of the pyaging implementation. # Usage: Rscript generate_references.R /tmp/CellDRIFT-original /tmp/celldrift_fixture_input.csv /tmp/celldrift_expected.csv args <- commandArgs(trailingOnly=TRUE) suppressPackageStartupMessages(library(glmnet)) for (f in list.files(file.path(args...
5714d4b599164b7653932dcd7ef7354fb1a0f29e9873f55f6fa8d75027c9a620
R
812
32
## ---Libraries ------ library(Signac) library(Seurat) library(GenomeInfoDb) library(EnsDb.Hsapiens.v86) library(ggplot2) library(dplyr) library(patchwork) library(rtracklayer) library(cowplot) #library(BSgenome.Hsapiens.UCSC.hg38) library(JASPAR2020) library(TFBSTools) library(patchwork) ##--- Functions -------- howM...
b187dc748eaba12c23f03df3c3fecf1e75c5fde7915f9fb78bd65fa1eb2ddb70
R
815
17
#' Extract number of variants for each chromosome in the VCF file #' #' This function extract the number of variants for each chromosome from the modeled VCF file #' #' @param SAMPLE_GT_CLEAN the modeled VCF file #' @param CHR_NAMES (optional) vector with chromosme names to plot #' @return A vector with number of varia...
c2ff90d7584a0a220a13f1afda6e200b0623f39a645753d75f2f7c523eedf2c2
R
817
29
## need package minpack.lm fitSinCurve <- function(xx, observed, parStart = list(A=3,phase=0, offset=0)){ getPred <- function(parS, xx) { parS$A * sin(2*pi/24 * (xx + parS$phase)) + parS$offset } residFun <- function(p, observed, xx) observed - getPred(p,xx) nls.out <- nls.lm(par=parStart, fn = residFun, obser...
76319ad3d5db7617efb15804e3e395fa0473256fe2aefa5495237595889fe9fd
R
826
37
### _gprofiler.R ### suppressPackageStartupMessages({ library(gprofiler2) }) gene_loader <- function(path){ stopifnot(is.character(path)) return(rownames(read.csv(path, header=T, row.names=1))) } egost <- function( gene, organism="rnorvegicus", correction_method="fdr", user_threshold=0...
c98e5261c1ff88439f2b45e2971e592f885954522158475a65bffbd69bd87615
R
828
26
### DATA zeisel <- read.table("zeisel.txt", sep = "\t", header = T) rownames(zeisel) <- zeisel[ , 1] zeisel <- zeisel[ , 3:dim(zeisel)[2]] zeisel <- as.matrix(zeisel) ### ANNOTATIONS labs <- read.table("zeisel.txt", nrows = 1, stringsAsFactors = F) labs <- as.character(labs[2:length(labs)]) ann <- data.frame(clust_id ...
5e6eec4113615a6e392c22710f555e6f0c2fe058c2aa02e255c86487a53a3f4d
R
831
21
library(dplyr) library(Seurat) ### merge datasets sObj_List1 <- readRDS(paste0("rObjects/sObj_List_", "run1", ".rds")) sObj_List2 <- readRDS(paste0("rObjects/sObj_List_", "run2", ".rds")) sObj_List <- c(sObj_List1, sObj_List2) saveRDS(sObj_List, paste0("rObjects/sObj_List_", "all", ".rds")) sObj_Filtered1 <- readRDS...
00c8935a4ff127fad8c23fdb9bdcfa58a7a2449cd2c8787f72b1b8b9151451d2
R
841
32
library(Signac) library(Seurat) library(GenomeInfoDb) library(EnsDb.Hsapiens.v86) library(ggplot2) library(dplyr) library(patchwork) library(rtracklayer) library(cowplot) set.seed(1234) sObj_Filtered <- sObj_cluster <- readRDS("rObjects/sObj_cluster.rds") sampleInfo <- readRDS("rObjects/SampleInfo.rds") ## add gene...
c188e880215acf2149cc78b916ed1a51a5dc10d70997c57c7c8c39d26b41dc93
R
843
22
# required external packages for SIMLR library("Matrix") library("parallel") # load the SIMLR R package source("./R/SIMLR_Estimate_Number_of_Clusters.R") source("./R/compute.multiple.kernel.R") source("./R/network.diffusion.R") # load the datasets load(file="./data/Test_4_Usoskin.RData") # in this example we test th...
7e56f42aaf97b47275e8de5851d0c0e51abc30d0424f3cbe9c43f5b46b7bd57b
R
848
25
### DATA d <- read.table("Goolam_et_al_2015_count_table.tsv", header = T) ### ANNOTATIONS labs <- colnames(d) labs[grep("4cell",labs)] = "4cell" labs[grep("8cell",labs)] = "8cell" labs[grep("16cell",labs)] = "16cell" labs[grep("32cell",labs)] = "blast" labs[grep("2cell",labs)] = "2cell" ann <- data.frame(cell_type1 = ...
9843e4e16768a49c5475b3faa55718cfa4c238315e473f79f308fac4548a38d4
R
866
26
### DATA d <- read.table("pancreas_refseq_rpkms_counts_3514sc.txt", stringsAsFactors = F) d <- d[!duplicated(d[,1]), ] rownames(d) <- d[,1] d <- d[,3:ncol(d)] d <- d[,3515:7028] labs <- read.table("labels.txt", stringsAsFactors = F, header = F) labs <- as.character(labs) colnames(d) <- labs d <- d[,order(colnames(d))] ...
7d45fb0e4e751e6d34ed547c8108aa0b96e3491c51bc669dd0685185b91b8988
R
870
14
source("/home/XXXXX/utils/R/run_scvi_integration.R") run_SCVI_integration(object = "/projects/b1038/Pulmonary/rgrant/microglia_aging_flu/scRNAseq/analysis/230118_human_microglia_penultimate.rds", python_path = "/projects/b1038/Pulmonary/rgrant/microglia_aging_flu/scRNAseq/human_microglia_venv/bin...
4c6aa47d83d93a9c36748cf75b69ccd9631eba3444d48696b32927728104533e
R
873
24
# Observational Analysis - Body Shape Phenotypes -> Colorectal cancer ## Load the file with the information on colorectal cancer cases table(cc_data_crc$colorectal) dd <- datadist(cc_data_crc) options(datadist='dd') ## Example of Cox regression ### Model was adjusted by socio-demographic and lifestyle factors as we...
eeb6290315666715749e7f125b9e588cb69d747178aa7a14e6744e50d4da2c33
R
874
27
### DATA d <- read.table("counttable_es.csv") d <- d[1:(nrow(d) - 5), ] ### ANNOTATIONS ann <- data.frame( cell_type1 = unlist(lapply(strsplit(colnames(d), "_"), "[[", 3)), batch = paste( unlist(lapply(strsplit(colnames(d), "_"), "[[", 3)), unlist(lapply(strsplit(colnames(d), "_"), "[[", 4)), ...
7766849e060b417b72b38ca5fd559304391269fb8ede916c0427bf3a4adceec8
R
887
28
#' Isler et al. (2008) dataset of primate brain and body mass. #' #' A dataset containing the brain and body mass of 74 primate species #' #' #' @format A data frame with 74 rows and 2 variables: #' \describe{ #' \item{Brain}{brain mass, in grams} #' \item{Body}{body mass, in grams} #' ... #' } #' @source Isler ...
988d5f236d272420993e2970226e1208a606cbb0e8722b95511a1062d82257a0
R
887
28
#' FindClusters() #' #' Perform cell clustering using different resolutions #' #' @param obj stCCA S3 Object #' @param resolution_list List of resolutions to use for clustering #' #' @export #' #' @import future.apply #' future #' Seurat FindClusters <- function(resolution_list, obj) { future::plan(multisession, wor...
87f840a8e436b673bf024b548216cb6091898b7fb5bd7744bfb2197d7507cb49
R
893
27
## Setup setwd("/cluster/p/p33/cluster/users/elizabept/multimodal/discovery/phenos/data/diffusion") library(ggplot2) library(data.table) library(nFactors) ## Load data PC = c(c(1:1000),c(1:1000),c(1:1000)) metric = c(rep("N0", 1000), rep("NF", 1000), rep("ND", 1000)) N0 = fread("N0_Eigenvalues.txt",data.table = F,head...
86a63d190d9b0a60a6f7edb54e8994b8aa4edbcdac76e458c334d87b5235fbf2
R
895
18
# Usage: Rscript generate_reference.R ORIGINAL_HPS_DIRECTORY FIXTURE_DIRECTORY # Source and execute the original author's function without modification. args <- commandArgs(trailingOnly=TRUE) source(file.path(args[1], "HPS.R")) input <- read.csv(file.path(args[2], "input_npx.csv"), row.names=1, check.names=FALSE) resul...
29bad9403be78aad9da64284ff77d205024b1aa6d7995cf74f82927ce580929f
R
899
26
### DATA d <- read.csv("Usoskin+et+al.+External+resources+Table+1.csv", stringsAsFactors = F) exprs_data <- data.matrix(d[11:nrow(d), 10:ncol(d)]) ann <- t(d[c(1:3, 5:8), 10:ncol(d)]) colnames(ann) <- d[c(1:3, 5:8), 9] colnames(ann)[5:7] <- c("cell_type1", "cell_type2", "cell_type3") # filter bad cells filt <- !grepl("...
7965745d6a24ccc6a12268b5303f2baf4dacdcb327344395242e048bd2597a9b
R
900
29
### DATA d <- read.csv("nsmb.2660-S2.csv") rownames(d) <- d[,1] d <- d[,3:92] ### ANNOTATIONS ct2 <- colnames(d) ct2[grepl("Oocyte", ct2)] <- "oocyte" ct2[grepl("Zygote", ct2)] <- "zygote" ct2[grepl("X2.cell", ct2)] <- "2cell" ct2[grepl("X4.cell", ct2)] <- "4cell" ct2[grepl("X8.cell", ct2)] <- "8cell" ct2[grepl("Morul...
c244910d574083b557190abdf776e5c60975253bf532ebd06cd0468af8484a3f
R
910
23
# Shared fixtures for the UCell test suite. # Random counts, with ties, as a plain matrix make_counts <- function(nfeat = 60, ncell = 40, seed = 42) { set.seed(seed) m <- matrix(rpois(nfeat * ncell, lambda = 3), nrow = nfeat, ncol = ncell) dimnames(m) <- list(paste0("gene", seq_len(nfeat)), ...
501bf27b146836bf9a01e64a8a92062bdfa7b9024a8a7159f9281ad55df27981
R
919
17
#' Load a FASTA file and get chromosomes characteristics #' #' This function loads the FASTA file and returns a Seqinfo object with length for each chromosome #' or with only specified chromosomes, if CHR_NAMES is given #' #' @param FASTA_FILE Path to the input FASTA file #' @param CHR_NAMES (optional) vector with chro...
699bcf42ac2d1c79a7c18ec25d297075a708c2b164d1483f522e8a3a71d73df6
R
919
18
--- title: "R Notebook" output: html_notebook --- This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code. Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Ct...
434d7d9c4476b637a9bdd95503b1e98a8a877ffb4a2aa4cad160554c08de0ceb
R
920
27
#Circadian Drawing circadianDrawing <- function(tod, expr, apar, labels, specInfo=NULL){ getPred <- function(parS, xx) { parS$A * sin(2*pi/24 * (xx + parS$phase)) + parS$offset } geneName <- apar$genes peak <- round(apar$peak) if(peak==18) peak <- -6 #pvalue <- signif(apar$pvalue,3) # amain <-...
ee9f0f41cb5d396dc2950f64e37989c97c207c726734b267d4a93500e6fe6969
R
925
25
# install.dependencies.gruffi.R # Install standard dependencies ------------------------------------------------ install.packages('pdist') install.packages('raster') install.packages('rgl') BiocManager::install("clusterProfiler") BiocManager::install("org.Hs.eg.db") # Install standard dependencies -----------------...
109ad8f31c92059732da83506e48802469c2fc06a38f5908cb9d0b48da4fbe5b
R
931
30
## Deseq2 for DGE ## cts <- as.matrix(read.delim("sum_rawcount_wt-axxc.txt", sep="\t", row.names="gene_name")) head(cts) coldata <- read.delim("coldata_AXXC-WT.txt") coldata coldata$condition <- factor(coldata$condition) library(DESeq2) dds <- DESeqDataSetFromMatrix(countData = cts, ...
c3b80531ad13c008aa4e3543ba5fd4cb892d3fef58c8acd9d6353995c28f9e1f
R
941
18
### Figure 4A rm(list = ls()) library("ggplot2") setwd("/Users/chenguangji/Desktop/05.内源性病毒/LTR/Solo-LTR_report/Solo-Final/Source_Data/Figure_4/Figure_4A/") ClosestGene<-read.table("Figure_4A.txt",sep="\t",header=T) ClosestGene$term<-factor(ClosestGene$term,levels=rev(c("all","H3K27ac","H3K4me3","H3K27me3"))) Closest...
64c241099d9f79428025896be53d5006ae2e5467186ffcfed9b96f67f4ac5a93
R
946
35
source('code/misc/miscfxns.R') rank_INT_base <- function(x,k=3/8){ mask <- x %in% c(-Inf,Inf,NaN,NA) x[!mask] <- qnorm((rank(x[!mask])-k)/(length(x[!mask]) - 2*k + 1)) return(x) } rank_INT <- function(x,k=3/8){ # INPUTS: # x: any R object # OUTPUTS: # that object normalized using rank inverse normal transfo...
97599ae2e862ca714566d9f458a4e05c3ad6c0e002024d4fbe82ab436ecfb723
R
955
18
# Usage: Rscript generate_reference.R ORIGINAL_PAC_DIRECTORY FIXTURE_DIRECTORY # Execute the pinned original author's function, not a rewritten formula. args <- commandArgs(trailingOnly=TRUE) source(file.path(args[1], "pac_proteomic_age.R")) input <- read.csv(file.path(args[2], "input_npx.csv"), row.names=1, check.name...
d6eb3dae169e42e0d282cc18089cbae133ad1bcb470b3f8f79fff11e148b2b7c
R
957
16
#' Lineage-specific rate estimation using multiple variance Brownian motion #' #' Computes lineage-specific rates using mvBM #' @param tree an object of class "phylo". #' @param tree_mvBM an object of class "phylo". The rescaled tree from an mvBM procedure. #' @param branches vector listing the branch numbers ('edge' ...
c043ac04439f1c7c77eb13f5d7dcdef0c575f8b3261ea301003c858eecec2c75
R
967
26
### This code creates fig. S3 library(ggplot2) library(tidyr) library(gridExtra) # read in the results from Dinvestigate Data <- read.table("P1_P2_P3_localFstats__100_50.txt",as.is=T,header=T) p1 <- ggplot(Data, aes(x=windowStart, y=D)) + geom_point() + xlim(c(21200000,21900000)) + xlab(paste("Scaffold 12")) + ...
528be821bcfc7657031d25bc1c4eeb3344dc69b8fa18b87dec9e1909dff0f848
R
976
37
## ---Libraries ------ library(Signac) library(Seurat) library(GenomeInfoDb) library(EnsDb.Hsapiens.v86) library(ggplot2) library(dplyr) library(patchwork) library(rtracklayer) library(cowplot) #library(BSgenome.Hsapiens.UCSC.hg38) library(JASPAR2020) library(TFBSTools) library(patchwork) ##--- Functions -------- howM...
7043a0cfdaba947ac3e5ffccb637a2a5e7a84517b6d26c4ae5afa1c7ab32f822
R
984
38
library(dplyr) library(VennDiagram) library(grid) # Read data dnn <- read.csv("feature_importance.csv") xgb <- read.csv("xbg_importance_matrix.csv") logit <- read.csv("logit_features.csv") # Calculate the 95th percentile for Importance and Gain dnn_percentile_95th <- quantile(dnn$Importance, probs = 0.95) xgb_percen...
7ebe2326d38fecfdf0ae62eed4850f6fdfb35a745878a914a130e2959ca8b97b
R
988
25
### DATA deng_rpkms <- read.table("deng-rpkms.txt", check.names = F, header = T) deng_reads <- read.table("deng-reads.txt", check.names = F, header = T) genes <- deng_rpkms[ , 1] deng_rpkms <- as.matrix(deng_rpkms[ , 2:ncol(deng_rpkms)]) rownames(deng_rpkms) <- genes deng_reads <- as.matrix(deng_reads[ , 2:ncol(deng_re...
29c8a2a572c97f142d538fcf8e40e0bfe0817772a4a27046f87f488e670ad72e
R
994
30
require("biomaRt") counts = read.table('data/counts.tsv', sep ='\t', stringsAsFactors = FALSE, header=TRUE, row.names=1) originalNames = rownames(counts) geneNames <- gsub("\\.[0-9]*$", "", originalNames) mart <- useMart("ENSEMBL_MART_ENSEMBL") mart <- useDataset("hsapiens_gene_ensembl", mart) annotLookup <- getBM(...
f6b2c080536f2f3b13ac0836de91f615f845e8e265333c76d8247d4f60fd2277
R
997
31
#' Create a vector with height to plot each variant #' #' This function defines the Y axis coordinate to plot each variant, based on the total variants in the VCF file #' #' @param CHR_N the vector with number of variants for each chrosomome (as returned by get_chr_num() function) #' @param ORDERED (optional) if user w...
0ee22965e54fca16c79fac7319dc82d842a7b73a72cdf036822e750ac3c9ae66
R
998
26
### DATA d <- read.table("data.csv", header = T, stringsAsFactors = F) ann <- read.table("cell_type_annotation_Cels2016.csv", stringsAsFactors = F) ### ANNOTATIONS d <- d[,colnames(d) %in% rownames(ann)] ann <- ann[rownames(ann) %in% colnames(d),,drop = FALSE] d <- d[,order(colnames(d))] ann <- ann[order(rownames(ann)...
f199dd8fb82d767c9d797497a55e4ff8167fe1d9f39c630f63d500a3a362c54f
R
1,001
24
# Figure 1B rm(list = ls()) require("writexl") library("dplyr",quietly=T) library("ggplot2",quietly = T) library("ggpubr",quietly = T) setwd("Source_Data/Figure_1/Figure_1B/") data.df.1B<-read_excel("Figure_1B.xlsx") ### Figure_2B p.Fig1B<-ggscatter(data.df.1B %>% mutate(clade=factor(clade,levels=c("Aves","Reptilia...
2cce21adf9bb24dbc80992776c945bd9e2447933f9f74db47e9155e5cc05cde5
R
1,016
38
library(Spaniel) library(scran) library(scater) library(batchelor) library(dplyr) library(Seurat) library(SCFunctionsV3) library(cowplot) library(RColorBrewer) library(SCFunctionsV3) library(harmony) allData <- "/data/rachel/Linda_Lako/Spatial/spaceranger_outs_2021_102" tissue <- "AD3" projDir <- paste0("/data/rache...
3561552deca0b4893ca6d5064abe895b412a20bd0cede87a4ab541c77dfbfe84
R
1,023
43
############################################################################################################ ########## R script for: ########## ########## Statistical indices of masculinity-femininity: A theoretical and practical framework. ########## ########## Marco Del Giudice ########## ########## Script for Fi...
b40d561d903005a867eab23c120248a778f94b181e7c82edcf12ae406df624d3
R
1,025
38
library(Spaniel) library(scran) library(scater) library(batchelor) library(dplyr) library(Seurat) library(SCFunctionsV3) library(cowplot) library(RColorBrewer) library(SCFunctionsV3) library(harmony) allData <- "/data/rachel/Linda_Lako/Spatial/spaceranger_outs_2021_102" tissue <- "fetal_retina" projDir <- paste0("/d...
0d400796e9648a9e664f492e0319dd8485c64917a9bcb1ec3ac3395a5df93da7
R
1,026
27
library(Seurat) library(SeuratObject) library(dplyr) library(ggplot2) # Read the Seurat object dat0 <- readRDS("PlateletsOnly_cluster_Anno.rds") # Update metadata within the Seurat object dat0 <- dat0 %>% mutate(seurat_clusters = paste0("C", seurat_clusters), seurat_clusters = factor(seurat_clusters, ...
43b741b1de66c60f8658905e5efe7617d60f245105c369371b0c5f50834de8ee
R
1,030
30
# Go through all sequence files and check whether they are ok. # Does each sequence have 16 images? # Does each sequence consist of unique images? library(tidyverse) sequence_length <- 10 # Identify sequence files # Juli: I changed the path because my project is in the main folder all_files <- list.files("./categor...
94cc3c6314e0ee5eea3313430b6e895a0d67ddd631f4724ddebf22ac66465efb
R
1,043
36
# # # require(tidyverse) require(tidygenomics) cyto=read_tsv("ucsc_mm10_cytoBand.txt.gz") %>% rename(chrom=`#chrom`) %>% mutate(chrom=gsub("^chr","",chrom)) cyto=cyto %>% mutate(CID=paste0("c",row_number())) %>% rename(start=chromStart,end=chromEnd) %>% mutate(band=paste0(chrom,name)) ar...
b137620e786aa8fb5fc41cb23c3034ee6caa1d939c9807beabed8274b4587e9d
R
1,044
28
### DATA # Human x1 = read.delim("GSE75330_Marques_et_al_mol_counts2.tab", "\t", header=T, stringsAsFactors=FALSE) ann <-read.table("Marq_Ann.txt", header=T, stringsAsFactors=FALSE) rownames(x1) <- x1[,1]; x1 <- x1[,-1]; x1 <- x1[, colnames(x1) %in% colnames(ann)] ### ANNOTATIONS ann <- ann[, colnames(ann) %in% colnam...
288906023eea01346fe8d6de9f56c98c3251847864918414547d8ed610dd2e2b
R
1,057
33
#! /usr/bin/env Rscript rm(list=ls()) library(data.table) Path = "/cluster/projects/p33/users/elizabept/multimodal/discovery/phenos/data" GenPath <- "/cluster/projects/p33/groups/imaging/ukbio/genetics" Batch="42k" Date="160320" ###################### # Merge all measures # ###################### DM <- fread(paste...
a6481a52dc3e45a07a708dd4dbe2fdc601e081f6e528248f88a558f4125e81d9
R
1,077
22
# File for creating some UMAPs for figure 2 library(plotly) reticulate::py_run_string("import sys") genes <- c("Atoh1", "Neurog1", "Ascl1", "Prdm13") for (i in genes) { Feature3D(data.combined, i) %>% layout(scene = list(camera = list(eye = list(x = .5, y = -1, z = 1.6)), ...
41962b4cc223541f33d6db6fe20d677b3fd004f0b3bc57bf38ed59f2f8b4d240
R
1,084
20
# Figure_4C require( ggplot2 ); require( scales ); require( ggrepel ); require( dplyr ) setwd("Source_Data/Figure_4/Figure_4C/") Brian_compare.DEGs.df<-read.csv("Figure_4C.csv") p.Volcano<- ggplot(Brian_compare.DEGs.df, aes(log2FoldChange,-1*log10(padj)))+ geom_point(aes(color = diffexpressed),al...
05a66634b5190ce7ff68e533bc51c00595fe51fde19ee78dbe3c1d50b76bb949
R
1,092
39
#! /usr/bin/env Rscript library(DropletUtils) mtx_dir <- "${input_mtx_dir}" sce <- read10xCounts(mtx_dir) # Read to SingleCellExperiment object print(sce) # Convert to matrix count_matrix <- counts(sce) rownames(count_matrix) <- rownames(sce) colnames(count_matrix) <- colData(sce)\$Barcode if ("${write_csv}" == "...
499f8e8156901edcf1cab9ac150f69a4d99743af570e278a80d47ad6dce948ed
R
1,094
31
#' plot_cluster() #' #' Visualizing clusters in human brain image #' #' @param coordis Spatial location of cells with cell barcode as rows and coordinates as columns. #' @param label Cluster label as a column of data frame. #' @param colors Color palette for clusters. #' @param t Plot Title. Null in default. #' @param ...
4d2eb8b29cfad5959a2d4b52e76fd1bac10c2b0b5026bfbd77b59872bd660962
R
1,099
34
CCAAlgorithm <- function(x,z,v,penaltyx,penaltyz,K,niter,trace,upos,uneg,vpos,vneg){ if(K>1) v.init <- v[colSums(z^2) != 0] if(K==1) v.init <- v[colSums(z^2) != 0] v.init <- matrix(v.init,ncol=K) u=v=d=NULL xres <- x; zres <- z xres <- x[, colSums(x^2) != 0] zres <- z[, colSums(x^2) != 0] ...
351a2781497b2487d6195fb1edbecd0a74661584ba04c9057515e2be35845646
R
1,101
32
#' CheckVS #' #' @param v v #' @param x x #' @param z z #' @param K K #' #' @import RSpectra CheckVs <- function(v,x,z,K){ # If v is NULL, then get v as appropriate. ##print(list(v=v, x = x, z = z, K = K)) if(!is.null(v) && !is.matrix(v)) v <- matrix(v,nrow=ncol(z)) if(!is.null(v) && ncol(v)<K) v <- NULL if(!is...
ebdc08e1166b2509303211d991ba1e764eeb81f3c4bbd107146adc3dd8f138c7
R
1,101
27
### DATA DATA = read.table("data.txt", header=T) expr_mat = as.matrix(DATA[,2:length(DATA[1,])]); keep = colSums(expr_mat> 0) > 100; # Some cell QC (avoid all zero cells) expr_mat = expr_mat[,keep]; gene_names = DATA[,1]; gene_names = matrix(unlist(strsplit(as.character(gene_names),"__")),ncol=2, byrow=T ) dups = dupli...
4c0aea988b97e4f209900957137fe8a0d1e8e27717f4325eafa4f3b7d7ff4a42
R
1,111
31
compareplots <- function(nameofref, nameoflookup, samplesize) { reflocation <- which(colnames(ReadsTable) == nameofref) lookuplocation <- which(colnames(ReadsTable) == nameoflookup) reference <- ReadsTable[,reflocation] lookup <- ReadsTable[,lookuplocation] referenceprop <- reference/sum(reference...
4084f295b1846a8c0d458d78aa1e56f2a86112c311e1f146adf25f5536e01856
R
1,128
33
library("stars") variables = list.files("data/variables", pattern = ".tif", full.names = TRUE) n = length(variables) df = data.frame(min = double(n), max = double(n), mean = double(n), sd = double(n)) for (i in seq_along(variables)) { cat(i, "/", n, "\n") r = read_stars(variables[i], proxy = FALSE) df[i, "min"]...
348a8ea7eec8cdff6211f555c9ed42bf05a7e700b50e02b7cd50de7e113ccfc1
R
1,133
36
setwd('/work/AnneSophiaHartebrodt#6698/ms-project/') require(rhdf5filters) require(rhdf5) require(Rhdf5lib) renv::activate('/work/AnneSophiaHartebrodt#6698/ms-project/r-single-cell') renv::repair() set.seed(11) require(Seurat) require(data.table) require(ggplot2) require(ggrepel) require(dplyr) require(tidyr) require(c...
06be487512d388aad9b5ebef50aff59d57072c447d20aab7be5de6878481e90e
R
1,140
18
#' Lineage-specific rate estimation using multiple variance Brownian motion #' #' Plots lineage-specific rates using mvBM #' @param tree an object of class "phylo". #' @param tree_mvBM an object of class "phylo". The rescaled tree from an mvBM procedure. #' @param branches vector listing the branch numbers ('edge' num...
e2957371b87c07d3e9f695ab3a0fe167c19acbff70804aa411223a1b52744b87
R
1,143
40
--- title: "License" output: workflowr::wflow_html: toc: false theme: cosmo highlight: textmate code_folding: hide df_print: paged editor_options: chunk_output_type: console --- This repository contains code and output of the analysis of single-nuclei RNA sequencing data for the article [Hevesi...
df7a87db16164b096080b78539476e98a3242c82007961af46fadf35c3d31570
R
1,147
34
library(dplyr) library(EnhancedVolcano) # Set parameters dpi <- 300 # Create Volcano Plot png(file = "NS_S_volcano_ML_features.png", width = dpi * 12, height = dpi * 6, units = "px", res = dpi, type = 'cairo') EnhancedVolcano(markers, lab = markers$gene, x = 'avg_log2FC', ...
491e21a9ba405e0af731224506af4e9138f21ee745e32c2d3216fbc690eb3cdd
R
1,156
33
library(monocle3) library(ggplot2) # Load the CellDataSet cds <- readRDS("pla_cds_C0_C1_C4_C6.rds") dpi = 300 # Generating Monocle 3 Trajectory plot colored by Seurat clusters png(file = "Monocle3_Traject_by_cluster.png", width = dpi * 6, height = dpi * 4, units = "px", res = dpi, type = 'cairo') plot_cells(cds, ...
015e4371664d6e31ae4650c78e70160de9f6767416d71a581a6ae860d4e165fc
R
1,177
42
#' sct() #' #' Apply variance stabilizing transformation to UMI count data using a regularized Negative Binomial regression model. This will remove unwanted effects from UMI data #' #' @param n_genes Number of genes #' @param obj stCCA S3 Object #' @param transpose Boolean of Matrix transpose #' #' @export #' #' @impor...
628a53e040d1aa1fd5d9fac4731521263ec51d42ca4b4abe428f20cd57609276
R
1,178
31
# Go through all sequence files and check whether they are ok. # Does each sequence have 16 images? # Does each sequence consist of unique images? library(tidyverse) # Identify sequence files all_files <- list.files("./graph", full.names = TRUE) sequence_files <- all_files[grepl("sequence_", all_files)] # Empty dat...
08ddf44a4f35f5cdeb0fd52a92d92ef2fa1f068add2e37f7a2c6c99e601473ed
R
1,181
31
# Go through all sequence files and check whether they are ok. # Does each sequence have 16 images? # Does each sequence consist of unique images? library(tidyverse) # Identify sequence files all_files <- list.files("./category", full.names = TRUE) sequence_files <- all_files[grepl("sequence_", all_files)] # Empty ...
4dd8bd0a9a53fef0095003ba0da86135935479ef4bf16229ad7a05de0720b5a4
R
1,191
31
#' return a vector of chromosome names in proper genomic order #' #' This function takes in a vector of chromosome names and return them in proper order #' #' @param CHR_VECTOR vector with chromosme names #' @return ordered vector of CHR_VECTOR chr_order <- function( CHR_VECTOR ){ CHR_NAMES38 <- c("chr1","chr2","chr3...
4429ffa9481472e95a4d70fa621a44a96b68062c38ec2cb399ac7017eaa1566e
R
1,198
33
library(Gviz) library(GenomicRanges) data(geneModels) library(TxDb.Mmusculus.UCSC.mm10.knownGene) library("org.Mm.eg.db") library(rtracklayer) geneRanges = import.gff("gencode.vM25.annotation.gtf") itrack <- IdeogramTrack(genome = "mm10", chromosome = "chr19") plotTracks(list(itrack),from = 10950000, to = 11650000) ...
e850d82603154459fa570e7385a112892fa573cbe2d8e38ba05457f436f4b99b
R
1,200
41
library(data.table) library(dplyr) ############ ## Load data ############ # Load Phenotypes PCs = fread("/path/ABCD11904_diffusion_QCed_230322.txt",data.table = F) PCs$IID = PCs$FID = sapply(strsplit(PCs$Row,"_"), `[`, 1) PCs$Row = paste0("NDAR_",PCs$IID) # Recommended inclusion inclusion = fread("/path/ABCDStudyNDA...
efb8d00767d138c57f8062d470b1ccf9c1ce2fe10583fa7771fda365f9029693
R
1,208
48
library(Signac) library(Seurat) library(GenomeInfoDb) library(EnsDb.Hsapiens.v86) library(ggplot2) library(dplyr) library(patchwork) library(rtracklayer) library(cowplot) set.seed(1234) sampleInfo <- readRDS("rObjects/SampleInfo.rds") sObj_predicted <- readRDS("rObjects/sObj_predictions.rds") anno_all <- read.csv(...
1894ff47116f340f7d741259c188c7f1d35d22c358d1954ab69cbe65eb13aa4f
R
1,224
40
#' spatial_gradient() #' #' Spatial-informed cell gradient plots #' #' @param t A character string to define plot title. Null in default. #' @param obj stCCA S3 Object #' #' @export #' #' @import ggplot2 #' ggpubr spatial_gradient <- function(obj, t = NULL) { coordis <- obj$spatial joint_embedding <- obj$joint_emb...
abcd466b36354614ae45d700556b508e3df686d76bba9a0595536f4f83993cbc
R
1,224
44
# Mendelian Randomization Analysis - Body Shape Phenotypes -> Colorectal cancer ## Load the file with summary data for the body shape phenotype and colorectal cancer ### In this, there are ### Genetic variants that surpass the 10^-8 threshold for each body shape and their match in GECCO consortium summary statistics...
108003aa8b085305c655121d4f0832b3dc9f91da666bfe6dd6c79cff0142cd8e
R
1,233
36
#' BuildSNNSeurat() #' #' Build SNN matrix by inputting canonical variates of spatial-driven canonical loading #' #' @param k.param Maximum number of nearest neighbors to compute. Default - 30. #' @param prune.SNN Sets the cutoff for acceptable Jaccard index when computing the neighborhood overlap for the SNN construc...
ee766f1e398409955a7bf12375147af94d419d40f7fce79e9ed8a21f464bfe76
R
1,242
36
### DATA x1 = read.delim("GSE74672_expressed_mols_with_classes.csv", ",", header=T, stringsAsFactors=FALSE) ann <-x1[1:11,] x1 <- x1[-1*(1:11),] rownames(x1) <- x1[,1]; x1 <- x1[,-1]; tmp <- ann[,1] ann <- ann[,-1] ### ANNOTATIONS SOURCE <- rep("hypothalamus", times=length(x1[1,])) #BATCH <- as.character(unlist(ann[,4...
38a917cca0090c1a19aabd20530e47340af0545072a1f3dc9a255c0081932864
R
1,253
24
# Configuration for the Package DESCRIPTION <- list( package.name = "gruffi", version = "1.5.6", title = "Gruffi identifies and removes stressed cells from brain organoid single-cell datasets.", description = "The Gruffi R package helps you (1) to identify stressed cells in single-cell RNA-seq datasets usin...
008bac29ed0db81ac5106d6732cd92655fd49dae83c1086c01c7134c883ec22b
R
1,257
37
# StoreRankings_UCell and the rankings2Uscore() scoring path test_that("StoreRankings_UCell returns a gene x cell sparse rank matrix", { m <- make_counts() ranks <- StoreRankings_UCell(m, ncores = 1) expect_s4_class(ranks, "dgCMatrix") expect_equal(dim(ranks), dim(m)) expect_equal(rownames(ranks), rownames(...
3a51439f673fcadd46e4b6872ab6e941f1dca240d63042fa907eb9cd976d7732
R
1,258
35
### Figure 3C rm(list = ls()) library("UpSetR") library("ComplexHeatmap") ### upset R setwd("Source_Data/Figure_3/Figure_3C/") upset.df<-read.csv("Figure_3C.csv",header = T,row.names=1) names(upset.df)[1]="taeGut1" m = make_comb_mat(upset.df) m2 = m[comb_size(m) <= 60] m3 = m2[comb_size(m2) >= 2] pdf("Figure_3C.pdf...
895277801166261300b6c94492a8a82d92ce130521aff94b40af6873a75822c9
R
1,259
50
# Load required libraries library(Seurat) library(dplyr) library(ggplot2) library(cowplot) library(tidyr) library(ggpubr) library(stringr) # Load the dataset dat0 <- readRDS("Platelets_cluster_Anno.rds") DefaultAssay(dat0) <- "RNA" # Function to perform operations and generate plots for a given group.by parameter g...
8059c1526667e3617b7948e81bdc598da6dcb7d11ae94a6d799bbdac93decd85
R
1,269
38
#! /usr/bin/env Rscript rm(list=ls()) library(data.table) library(readr) Path = "/cluster/projects/p33/users/elizabept/multimodal/discovery/phenos" GenPath <- "/cluster/projects/p33/groups/imaging/ukbio/genetics" Batch="42k" Date="160320" ###################### # Merge all measures # ###################### daniel_...
573ce3055cc464ea78231047b3d91be1f37aa1455c767bd1bca9160e798bc08d
R
1,273
39
CalibrateNr <- function(Standards, SamplesToCalibrate, outputfilename) { standards <- read.csv(Standards) samples <- read.csv(SamplesToCalibrate, row.names = 1) cfu <- log10(standards[,1]) nr <- log10(standards[,2]) fit <- smooth.spline(x = cfu, y = nr, df = 7) xvals <- seq(from = min(cfu), to = 7...
cf8908d2c3cb4f6e27b0b83c8e616ea0d7117511479a3aa5517dc307fe9c876c
R
1,273
39
CalibrateNs <- function(Standards, SamplesToCalibrate, outputfilename) { standards <- read.csv(Standards) samples <- read.csv(SamplesToCalibrate, row.names = 1) cfu <- log10(standards[,1]) ns <- log10(standards[,2]) fit <- smooth.spline(x = cfu, y = ns, df = 7) xvals <- seq(from = min(cfu), to = 7...
1c64c7ac705184d51df86e4298d78d9abb1e2e0a53c950c216ecac2de36c6047
R
1,284
36
library(ggplot2) setwd("R:/WeijieZheng/Social_defeat_csv") data <- read.csv("I_O_difference_level6.csv") ggplot(data, aes(log2FoldChange, -log10(pValue)))+ geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "#999999")+ geom_vline(xintercept = c(-0.5, 0.5), linetype = "dashed", color = "#999999")...
554a5e2e9304b1a510645ce90ed1ce1f8529635ea3f5ef69be49e19186aee22d
R
1,284
24
library(dplyr) devtools::load_all('breaktools/') common_motif = function() { rdc_df = readr::read_tsv("data/rdc.tsv") %>% dplyr::filter(tlx_group=="APH-Inter" & rdc_subset=="Wei+DKFZ" & rdc_is_significant) %>% dplyr::select(-tlx_group, -rdc_subset) %>% dplyr::do(as.data.frame(get_seq("genomes/mm10/mm10.f...