forked from GreenleafLab/ArchR
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.Rhistory
335 lines (335 loc) · 11.5 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
---
title: "ArchR Hematopoiesis Tutorial"
author: "Jeffrey Granja"
date: "11/22/2019"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(echo = TRUE)
summary(cars)
plot(pressure)
knitr::opts_chunk$set(echo = TRUE)
setwd("~/Documents/Heme_Tutorial/")
data("geneAnnoHg19")
data("genomeAnnoHg19")
threads <- 8
pathFragments <- "Heme_Fragments"
inputFiles <- list.files(pathFragments, pattern = ".gz", full.names = TRUE)
names(inputFiles) <- gsub(".fragments.tsv.gz", "", list.files(pathFragments, pattern = ".gz"))
inputFiles <- inputFiles[!grepl(".tbi", inputFiles)]
inputFiles
knitr::opts_chunk$set(echo = TRUE)
#Input Libraries
library(ArchR)
#Set/Create Working Directory to Folder
setwd("~/Documents/Heme_Tutorial/")
#Load Genome Annotations
data("geneAnnoHg19")
data("genomeAnnoHg19")
#Set Threads to be used
threads <- 8
pathFragments <- "Heme_Fragments"
inputFiles <- list.files(pathFragments, pattern = ".gz", full.names = TRUE)
names(inputFiles) <- gsub(".fragments.tsv.gz", "", list.files(pathFragments, pattern = ".gz"))
inputFiles <- inputFiles[!grepl(".tbi", inputFiles)]
inputFiles
#Input Libraries
library(ArchR)
#Set/Create Working Directory to Folder
setwd("~/Documents/Heme_Tutorial/")
#Load Genome Annotations
data("geneAnnoHg19")
data("genomeAnnoHg19")
#Set Threads to be used
threads <- 8
knitr::opts_chunk$set(echo = TRUE)
opts_knit$set(root.dir = "~/Documents/Heme_Tutorial/")
library(knitr)
knitr::opts_chunk$set(echo = TRUE)
opts_knit$set(root.dir = "~/Documents/Heme_Tutorial/")
#Input Libraries
library(ArchR)
#Load Genome Annotations
data("geneAnnoHg19")
data("genomeAnnoHg19")
#Set Threads to be used
threads <- 8
pathFragments <- "Heme_Fragments"
inputFiles <- list.files(pathFragments, pattern = ".gz", full.names = TRUE)
names(inputFiles) <- gsub(".fragments.tsv.gz", "", list.files(pathFragments, pattern = ".gz"))
inputFiles <- inputFiles[!grepl(".tbi", inputFiles)]
inputFiles
#Input Libraries
library(ArchR)
#Load Genome Annotations
data("geneAnnoHg19")
data("genomeAnnoHg19")
#Set Threads to be used
threads <- 8
library(knitr)
knitr::opts_chunk$set(echo = TRUE)
opts_knit$set(root.dir = "~/Documents/Heme_Tutorial/")
#Input Libraries
library(ArchR)
#Load Genome Annotations
data("geneAnnoHg19")
data("genomeAnnoHg19")
#Set Threads to be used
threads <- 8
pathFragments <- "Heme_Fragments"
inputFiles <- list.files(pathFragments, pattern = ".gz", full.names = TRUE)
names(inputFiles) <- gsub(".fragments.tsv.gz", "", list.files(pathFragments, pattern = ".gz"))
inputFiles <- inputFiles[!grepl(".tbi", inputFiles)]
inputFiles
#Input Libraries
library(ArchR)
#Load Genome Annotations
data("geneAnnoHg19")
data("genomeAnnoHg19")
#Set Threads to be used
threads <- 8
library(knitr)
knitr::opts_chunk$set(echo = TRUE)
opts_knit$set(root.dir = "~/Documents/Heme_Tutorial/")
library(ArchR)
#Input Libraries
library(ArchR)
#Load Genome Annotations
data("geneAnnoHg19")
data("genomeAnnoHg19")
#Set Threads to be used
threads <- 8
pathFragments <- "Heme_Fragments"
inputFiles <- list.files(pathFragments, pattern = ".gz", full.names = TRUE)
names(inputFiles) <- gsub(".fragments.tsv.gz", "", list.files(pathFragments, pattern = ".gz"))
inputFiles <- inputFiles[!grepl(".tbi", inputFiles)]
inputFiles
library(knitr)
knitr::opts_chunk$set(echo = TRUE)
opts_knit$set(root.dir = "~/Documents/Heme_Tutorial/")
library(ArchR)
#Load Genome Annotations
data("geneAnnoHg19")
data("genomeAnnoHg19")
#Set Threads to be used
threads <- 8
pathFragments <- "Heme_Fragments"
inputFiles <- list.files(pathFragments, pattern = ".gz", full.names = TRUE)
names(inputFiles) <- gsub(".fragments.tsv.gz", "", list.files(pathFragments, pattern = ".gz"))
inputFiles <- inputFiles[!grepl(".tbi", inputFiles)]
inputFiles
ArrowFiles <- createArrowFiles(
inputFiles = inputFiles[3],
sampleNames = names(inputFiles),
geneAnno = geneAnnoHg19,
genomeAnno = genomeAnnoHg19,
threads = threads,
force = TRUE
)
ArrowFiles <- createArrowFiles(
inputFiles = inputFiles[3],
sampleNames = names(inputFiles)[3],
geneAnno = geneAnnoHg19,
genomeAnno = genomeAnnoHg19,
threads = threads,
force = TRUE
)
ls
```{r eval=TRUE, cache=TRUE}
ArrowFiles <- createArrowFiles(
inputFiles = inputFiles[3],
sampleNames = names(inputFiles)[3],
geneAnno = geneAnnoHg19,
genomeAnno = genomeAnnoHg19,
threads = threads,
addGeneScoreMat = FALSE,
addTileMat = FALSE,
force = TRUE
)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(eval = FALSE)
# Small fig.width
knitr::include_graphics("~/Documents/Heme_Tutorial/Heme_Tutorial/Plots/Plot-UMAP-TileLSI_Date-2019-11-22_Time-01-35-25.pdf")
# Small fig.width
knitr::include_graphics("~/Documents/Heme_Tutorial/Heme_Tutorial/Plots/Plot-UMAP-TileLSI_Date-2019-11-22_Time-01-35-25.pdf")
# Small fig.width
knitr::include_graphics("~/Documents/Heme_Tutorial/Heme_Tutorial/Plots/Plot-UMAP-TileLSI_Date-2019-11-22_Time-01-35-25.pdf")
getwd()
"/Users/jeffreygranja/Documents/Heme_Tutorial/Heme_Tutorial/Plots/Plot-UMAP-TileLSI_Date-2019-11-22_Time-01-35-25.pdf
# Small fig.width
knitr::include_graphics("/Users/jeffreygranja/Documents/Heme_Tutorial/Heme_Tutorial/Plots/Plot-UMAP-TileLSI_Date-2019-11-22_Time-01-35-25.pdf")
# Small fig.width
knitr::include_graphics("/Users/jeffreygranja/Documents/Heme_Tutorial/Heme_Tutorial/Plots/Plot-UMAP-TileLSI_Date-2019-11-22_Time-01-35-25.pdf")
"~/Documents/HemeAll/heme/Plots/Plot-Tracks_Date-2019-11-17_Time-17-52-02.pdf"
knitr::include_graphics(path.expand("~/Documents/HemeAll/heme/Plots/Plot-Tracks_Date-2019-11-17_Time-17-52-02.pdf"))
file.copy
list.files()
list.files()
system("cp ~/Documents/HemeAll/heme/Plots/Plot-Tracks_Date-2019-11-17_Time-17-52-02.pdf mychart.pdf")
knitr::include_graphics(path = "mychart.pdf")
"mychart.pdf"
knitr::include_graphics(path = "mychart.pdf")#path.expand("~/Documents/HemeAll/heme/Plots/Plot-Tracks_Date-2019-11-17_Time-17-52-02.pdf"))
knitr::include_graphics(path = "mychart.pdf")
knitr::opts_chunk$set(echo = TRUE)
```{r pressure, echo=FALSE, eval = FALSE}
sessionInfo()
head(sessionInfo())
suppressPackageStartupMessages()
Sys.info()
.Platform
parallel::detectCores()
try(system("grep MemTotal /proc/meminfo", intern = TRUE), silent = TRUE)
ram = substring(system("sysctl hw.memsize", intern = TRUE), 13) #nocov
ram
ram / 10^9
as.numeric(ram) / 10^9
get_windows_ram = function() {
ram = try(system("grep MemTotal /proc/meminfo", intern = TRUE), silent = TRUE)
if (class(ram) != "try-error" && length(ram) != 0) {
ram = strsplit(ram, " ")[[1]]
ram = as.numeric(ram[length(ram) - 1])
ram_size = ram
} else {
# Fallback: This was the old method I used
# It worked for Windows 7 and below.
ram_size = system("wmic MemoryChip get Capacity", intern = TRUE)[-1]
}
return(ram_size)
}
system_ram = function(os) {
if (length(grep("^linux", os))) {
cmd = "awk '/MemTotal/ {print $2}' /proc/meminfo"
ram = system(cmd, intern = TRUE)
} else if (length(grep("^darwin", os))) {
ram = substring(system("sysctl hw.memsize", intern = TRUE), 13) #nocov
} else if (length(grep("^solaris", os))) {
cmd = "prtconf | grep Memory" # nocov
ram = system(cmd, intern = TRUE) ## Memory size: XXX Megabytes # nocov
} else {
ram = get_windows_ram() # nocov
}
ram
}
#' Get the amount of RAM
#'
#' Attempt to extract the amount of RAM on the current machine. This is OS
#' specific:
#' \itemize{
#' \item Linux: \code{proc/meminfo}
#' \item Apple: \code{system_profiler -detailLevel mini}
#' \item Windows: \code{memory.size()}
#' \item Solaris: \code{prtconf}
#' }
#' A value of \code{NA} is return if it isn't possible to determine the amount of RAM.
#' @export
#' @references The \code{print.bytes} function was taken from the \pkg{pryr} package.
#' @examples
#' ## Return (and pretty print) the amount of RAM
#' get_ram()
get_ram = function() {
os = R.version$os
ram = suppressWarnings(try(system_ram(os), silent = TRUE))
if (class(ram) == "try-error" || length(ram) == 0) {
message("\t Unable to detect your RAM. # nocov
Please raise an issue at https://github.com/csgillespie/benchmarkme") # nocov
ram = structure(NA, class = "ram") # nocov
} else {
cleaned_ram = suppressWarnings(try(clean_ram(ram, os), silent = TRUE))
if (class(cleaned_ram) == "try-error" || length(ram) == 0) {
message("\t Unable to detect your RAM. # nocov
Please raise an issue at https://github.com/csgillespie/benchmarkme") # nocov
ram = structure(NA, class = "ram") #nocov
} else {
ram = structure(cleaned_ram, class = "ram")
}
}
return(ram)
}
#' @rawNamespace S3method(print,ram)
print.ram = function(x, digits = 3, unit_system = c("metric", "iec"), ...) {
#unit_system = match.arg(unit_system)
unit_system = "metric"
base = switch(unit_system, metric = 1000, iec = 1024)
power = min(floor(log(abs(x), base)), 8)
if (is.na(x) || power < 1) {
unit = "B"
} else {
unit_labels = switch(
unit_system,
metric = c("kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"),
iec = c("KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB")
)
unit = unit_labels[[power]]
x = x / (base^power)
}
formatted = format(signif(x, digits = digits), big.mark = ",",
scientific = FALSE, ...)
cat(unclass(formatted), " ", unit, "\n", sep = "")
invisible(paste(unclass(formatted), unit))
}
get_ram()
plot(cars)
```{r eval = TRUE}
```{r}
suppressPackageStartupMessages(library(SnapATAC))
suppressPackageStartupMessages(library(SnapATAC))
suppressPackageStartupMessages(library(magrittr))
setwd("/Volumes/JG_SSD_2/Data/Analysis/Tutorial/test-snap")
parallel::detectCores()
Sys.Date()
sessionInfo()
#5k
if(!file.exists("atac_pbmc_5k_nextgem_fragments.tsv.gz")){
system("wget http://cf.10xgenomics.com/samples/cell-atac/1.2.0/atac_pbmc_5k_nextgem/atac_pbmc_5k_nextgem_fragments.tsv.gz")
system("wget http://cf.10xgenomics.com/samples/cell-atac/1.2.0/atac_pbmc_5k_nextgem/atac_pbmc_5k_nextgem_fragments.tsv.gz.tbi")
}
#10k
if(!file.exists("atac_pbmc_10k_nextgem_fragments.tsv.gz")){
system("wget http://cf.10xgenomics.com/samples/cell-atac/1.2.0/atac_pbmc_10k_nextgem/atac_pbmc_10k_nextgem_fragments.tsv.gz")
system("wget http://cf.10xgenomics.com/samples/cell-atac/1.2.0/atac_pbmc_10k_nextgem/atac_pbmc_10k_nextgem_fragments.tsv.gz.tbi")
}
#Analysis of 10x Fragment Files
#Install pip install -user snaptools
snapTools <- "/Users/jeffreygranja/Library/Python/2.7/bin/snaptools"
#Fragment Files
fragFiles <- c(
"atac_pbmc_5k_nextgem_fragments.tsv.gz",
"atac_pbmc_10k_nextgem_fragments.tsv.gz"
)
#Input Genome
genome <- "hg19"
if(!file.exists(paste0(genome,".chrom.sizes"))){
system(paste0("wget http://hgdownload.cse.ucsc.edu/goldenpath/",genome,"/bigZips/",genome,".chrom.sizes"))
}
#Download/Set Up 10x Fragment Files
#5k
if(!file.exists("atac_pbmc_5k_nextgem_fragments.tsv.gz")){
system("wget http://cf.10xgenomics.com/samples/cell-atac/1.2.0/atac_pbmc_5k_nextgem/atac_pbmc_5k_nextgem_fragments.tsv.gz")
system("wget http://cf.10xgenomics.com/samples/cell-atac/1.2.0/atac_pbmc_5k_nextgem/atac_pbmc_5k_nextgem_fragments.tsv.gz.tbi")
}
#10k
if(!file.exists("atac_pbmc_10k_nextgem_fragments.tsv.gz")){
system("wget http://cf.10xgenomics.com/samples/cell-atac/1.2.0/atac_pbmc_10k_nextgem/atac_pbmc_10k_nextgem_fragments.tsv.gz")
system("wget http://cf.10xgenomics.com/samples/cell-atac/1.2.0/atac_pbmc_10k_nextgem/atac_pbmc_10k_nextgem_fragments.tsv.gz.tbi")
}
#Analysis of 10x Fragment Files
#Install pip install -user snaptools
snapTools <- "/Users/jeffreygranja/Library/Python/2.7/bin/snaptools"
#Fragment Files
fragFiles <- c(
"atac_pbmc_5k_nextgem_fragments.tsv.gz",
"atac_pbmc_10k_nextgem_fragments.tsv.gz"
)
#Input Genome
genome <- "hg19"
if(!file.exists(paste0(genome,".chrom.sizes"))){
system(paste0("wget http://hgdownload.cse.ucsc.edu/goldenpath/",genome,"/bigZips/",genome,".chrom.sizes"))
}
setwd("~/Documents/GitHub/ArchR")
pkgdown::build_site()
warnings()
pkgdown::build_site()