-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.Rhistory
512 lines (512 loc) · 16.9 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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
table(Idents(exampleSeuratObjectUnlabelled))
createRFModel(exampleSeuratObjectLabelled)
Idents(exampleSeuratObjectLabelled)
table <- as.data.frame(as.matrix(exampleSeuratObjectLabelled$Idents))
table <- as.data.frame(as.matrix(Idents(exampleSeuratObjectLabelled)))
head(table)
library(rfca)
createRFModel(exampleSeuratObjectLabelled)
tm <- createRFModel(exampleSeuratObjectLabelled)
predictCells(exampleSeuratObjectUnlabelled, tm)
tm
predictCells(exampleSeuratObjectUnlabelled)
library(rfca)
tm <- createRFModel(exampleSeuratObjectLabelled)
tso <- createSeuratObjectPipeline()
predictCells(tso)
library(rfca)
library(Seurat)
unl <- createSeuratObjectPipeline()
rfm <- createRFModel(exampleSeuratObjectLabelled)
labelled <- predictCells(unl, rfModel = rfm)
library(rfca)
rfm <- createRFModel(exampleSeuratObjectLabelled)
rfm
predictCells(unl, rfModel = rfm[1], genelist = rfm[2])
rfm[1]
rfm[2]
length(rfm[2])
library(rfca)
createRFModel(exampleSeuratObjectLabelled)
rfm <- createRFModel(exampleSeuratObjectLabelled)
l <- varUsed(rfm)
library(randomForest)
l <- varUsed(rfm)
l
l <- varUsed(rfm, count = FALSE)
l
importance(rfm)
dim(importance(rfm))
importance(rfm)[1]
importance(rfm)[, 1]
row.names(importance(rfm))
document()
rfm
library(rfca)
predictCells(unl)
unl <- createSeuratObjectPipeline()
predictCells(unl)
rfm
predictCells(unl, rfModel= rfm)
predictCells(unl, rfm)
library(rfca)
predictCells(unl, rfm)
predictCells(unl)
git remote add origin https://github.com/kimberle9/rfca
setwd("~/Desktop/rfca")
library(devtools)
build_readme()
library(rfca)
build_readme()
document()
build_readme()
build_readme()
build_readme()
library(devtools)
document()
document()
library(rfca)
gsl <- list()
gsl$Microglia <- c("P2ry12", "Apoe")
gsl$Oligo <- c("Mbp", "Olig2", "Mobp")
gsl
p <- cellMarkerPlots(exampleSeuratObjectLabelled, gsl)
p
head(rfm)
rfm
head(importance(rfm))
head(importance(rfm)[, 1])
importance(rfm[,5])
importance(rfm)[, 1]
importance(rfm)[, 5]
sort(importance(rfm)[, 5])
sort(importance(rfm)[, 5], descending = TRUE)
sort(importance(rfm)[, 5], decreasing = TRUE)
dim(sort(importance(rfm)[, 5], decreasing = TRUE))
length(sort(importance(rfm)[, 5], decreasing = TRUE))
names((importance(rfm)[, 5], decreasing = TRUE)[1:10])
c <- names((importance(rfm)[, 5], decreasing = TRUE))
names(sort(importance(rfm)[, 5], decreasing = TRUE))[1:10]
n <- ncol(importance(rfm)) -2
n
x <-2
col.names(importance(rfModel))[x]
colnames(importance(rfModel))[x]
colnames(importance(rfm))[x]
colnames(importance(rfm))
document()
g <- createGeneLists(rfm)
g
vec <- colnames(importance(rfm))
vec <- vec[1:length(vec)-2]
l <- length(vec)-2
vec <- vec[1:l]
vec
importance(rfm)$Astrocytes
createGeneLists(rfm)
document()
createGeneLists(rfm)
g <- createGeneLists(rfm)
g
df <- importance(rfModel)
df <- importance(rfm)
cellTypeList <- which( colnames(df) == "Microglia")
cellTypeList <- names(sort(cellTypeList, decreasing = TRUE))[1:10]
cellTypeList
cellTypeList <- which( colnames(df) == "Microglia")
cellTypeList
colnames(df)
df[which( colnames(df) == "cellType=="Tcells"")]
cellTypeList <- df[, which(colnames(df) == "Microglia")]
cellTypeList
cellTypeList <- names(sort(cellTypeList, decreasing = TRUE))[1:10]
cellTypeList
document()
createGeneLists(rfm)
document()
createGeneLists(rfm)
g <- createGeneLists(rfm)
p <- cellMarkerPlots(exampleSeuratObjectLabelled, g)
g
p <- cellMarkerPlots(exampleSeuratObjectLabelled, geneList = g)
document()
p <- cellMarkerPlots(exampleSeuratObjectLabelled, g)
p
library(Seurat)
DimPlot(exampleSeuratObjectLabelled)
rm(exampleSeuratObjectUnlabelled)
DimPlot(exampleSeuratObjectUnlabelled)
rm(exampleSeuratObjectUnlabelled)
View(exampleSeuratObjectLabelled)
library(devtools)
build_readme()
build_readme()
build_readme()
build_readme()
build_readme()
build_readme()
build_readme()
build_readme()
build_readme()
build_readme()
build_readme()
build_readme()
build_readme()
build_readme()
library(Seurat)
?FeaturePlot
document()
p <- cellMarkerPlots(exampleSeuratObjectUnlabelled)
p
p <- cellMarkerPlots(exampleSeuratObjectUnlabelled, g)
p
document()
build_readme()
oligosonly <- subset(x = exampleSeuratObjectLabelled, idents = "Oligodendrocytes")
head(oligosonly[[]])
oligosonly <- FindVariableFeatures(oligosonly, selection.method = "vst")
all.genes <- rownames(oligosonly)
seurat.obj <- ScaleData(oligosonly, features = all.genes)
seurat.obj <- RunPCA(seurat.obj, features = VariableFeatures(object = seurat.obj))
oligosonly <- ScaleData(oligosonly, features = all.genes)
oligosonly <- RunPCA(oligosonly, features = VariableFeatures(object = oligosonly))
ElbowPlot(oligosonly)
oligosonly<- FindNeighbors(oligosonly, dims = 1:14)
oligosonly <- FindClusters(oligosonly, resolution = 0.6)
oligosonly <- RunUMAP(oligosonly, dims = 1:14)
DimPlot(oligosonly)
oligosonly
FeaturePlot(oligosonly, c("C4b", "Serpina3n"))
FeaturePlot(oligosonly, "Klk6")
build_readme()
View(exampleSeuratObject)
build_readme()
?build_manual
build_manual()
use_vignette("vignette")
table(Idents(exampleSeuratObjectLabelled))
exampleSeuratObjectLabelled
build_readme()
myList <- list()
clear()
myList$Microglia <- c("Cd11b", "Apoe")
myList$Oligodendrocytes <- c("Mbp", "Mobp", "Cldn11"
)
myList
build_readme()
install.packages("pkgdown")
library(pkgdown)
usethis::use_pkgdown()
pkgdown::build_site()
usethis::use_github_action("pkgdown")
pkgdown::build_site()
build_readme()
pkgdown::build_site()
tso
mySeuratObject <-tso
library(rfca)
predictCells(mySeuratObject)
rfm
myRandomForestModel <- rfm
predictCells(mySeuratObject)
predictCells(mySeuratObject, myRandomForestModel)
build_readme()
build_readme()
document*()
document()
build_readme()
library(Seurat)
pbmc <- readRDS(file = "../data/pbmc3k_final.rds")
setwd("~/Desktop")
pbmc.data <- Read10X(data.dir = "../hg19/")
pbmc.data <- Read10X(data.dir = "hg19")
pbmc <- CreateSeuratObject(counts = pbmc.data, project = "pbmc3k", min.cells = 3, min.features = 200)
pbmc
pbmc[["percent.mt"]] <- PercentageFeatureSet(pbmc, pattern = "^MT-")
pbmc <- subset(pbmc, subset = nFeature_RNA > 200 & nFeature_RNA < 2500 & percent.mt < 5)
pbmc <- NormalizeData(pbmc, normalization.method = "LogNormalize", scale.factor = 10000)
pbmc <- NormalizeData(pbmc)
pbmc <- FindVariableFeatures(pbmc, selection.method = "vst", nfeatures = 2000)
all.genes <- rownames(pbmc)
pbmc <- ScaleData(pbmc, features = all.genes)
pbmc <- RunPCA(pbmc, features = VariableFeatures(object = pbmc))
pbmc <- FindNeighbors(pbmc, dims = 1:10)
pbmc <- FindClusters(pbmc, resolution = 0.5)
pbmc <- RunUMAP(pbmc, dims = 1:10)
DimPlot(pbmc, reduction = "umap")
new.cluster.ids <- c("Naive CD4 T", "Memory CD4 T", "CD14+ Mono", "B", "CD8 T", "FCGR3A+ Mono",
"NK", "DC", "Platelet")
names(new.cluster.ids) <- levels(pbmc)
pbmc <- RenameIdents(pbmc, new.cluster.ids)
DimPlot(pbmc, reduction = "umap", label = TRUE, pt.size = 0.5) + NoLegend()
library(randomForest)
pbmc
library(rfca)
humanPBMC <- createRFModel(pbmc)
head(pbmc[[]])
Idents(pbmc) <- seurat_clusters
Idents(pbmc) <- pbmc$seurat_clusters
new.cluster.ids <- c("Tcells", "Tcells", "Monocytes", "Bcells", "Tcells", "Monocytes", "NKcells", "dendriticCells", "Platelets")
names(new.cluster.ids) <- levels(pbmc)
pbmc <- RenameIdents(pbmc, new.cluster.ids)
DimPlot(pbmc, reduction = "umap", label = TRUE, pt.size = 0.5) + NoLegend()
humanPBMC <- createRFModel(pbmc)
mouseBrain <- readRDS("rfmodel.RDS")
mouseBrain
humanPBMC
t <- createSeuratObjectPipeline()
FeaturePlot(t, c("Ms4a1", "Ncr1", "Cd3e"))
FeaturePlot(t, c("Col1a1", "Pdgfrb", "Pdgfra", "Plp1"))
FeaturePlot(t, c("Cd209a", "Fcgr1", "Cdh5", "Acta2"))
FeaturePlot(t, c("Mylk", "Sncg", "Des", "Tagln"))
FeaturePlot(t, c("Mylk", "Sncg", "Des", "Ly6c1"))
FeaturePlot(t, c("Wif1", "Tbx20", "Dkk3", "Lamc1"))
FeaturePlot(t, c("Wif1", "Tbx20", "Mrc1", "Dab2"))
FeaturePlot(t, c("Wif1", "Myh11", "Kcnj8", "Vtn"))
DimPlot(t)
a <- t
a.markers <- FindAllMarkers(a, only.pos = TRUE, min.pct = 0.25, logfc.threshold = 0.25)
a.markers %>% group_by(cluster) %>% top_n(n = 3, wt = avg_logFC) %>% print(n = 100)
library(magrittr)
library(dplyr)
a.markers %>% group_by(cluster) %>% top_n(n = 3, wt = avg_logFC) %>% print(n = 100)
t <- dget("droplet_Heart_and_Aorta_seurat_tiss.Robj")
t <- dget("droplet_Heart_and_Aorta_seurat_tiss.robj")
t = dget("droplet_Heart_and_Aorta_seurat_tiss.robj")
t <- dget("https://ndownloader.figshare.com/files/13088642")
t <- load("droplet_Heart_and_Aorta_seurat_tiss.robj")
t
tiss
head(tiss[[]])
Idents(tiss)
t <- UpdateSeuratObject(tiss)
t
head(t[[]])
table(t$cell_ontology_class)
mouseBrain
humanPBMC
l <- load("droplet_Liver_seurat_tiss.Robj")
l <- UpdateSeuratObject(l)
l
l <- UpdateSeuratObject(tiss)
head(l[[]])
table(l$cell_ontology_class)
table(l$subtissue)
Idents(l) <- l$cell_ontology_class
mouseLiver <- createRFModel(l)
mouseLiver <- createRFModel(l)
View(mouseLiver)
l <- load("facs_Liver_seurat_tiss.Robj")
l
l <- UpdateSeuratObject(tiss)
head(l[[]])
table(l$cell_ontology_class)
library(rfca)
library(Seurat)
library(randomForest)
l
l <- load("facs_Liver_seurat_tiss.Robj")
l1 <- UpdateSeuratObject(tiss)
l <- load("droplet_Liver_seurat_tiss.Robj")
l2 <- UpdateSeuratObject(tiss)
l <- merge(l1, y = l2)
l
head(l[[]])
table(l$cell_ontology_class)
Idents(l) <- l$cell_ontology_class
mouseLiver <- createRFModel(l)
k1 <- load("droplet_Kidney_seurat_tiss.Robj")
k1
k1 <- UpdateSeuratObject(tiss)
k2 <- load("facs_Kidney_seurat_tiss.Robj")
k1
k2 <- UpdateSeuratObject(tiss)
ks
k2
k <- merge(k1, y= k2)
k
mouseKidney <- createRFModel(k)
k
Idents(k) <- k$cell_ontology_class
Idents(k)
mouseKidney <- createRFModel(k)
f <- load("facs_Fat_seurat_tiss.Robj")
f <- UpdateSeuratObject(tiss)
table(f$cell_ontology_class)
Idents(f) <- f$cell_ontology_class
f
mouseFat <- createRFModel(f)
Idents(f)
mouseFat <- createRFModel(f, nfeatures = 100)
table(f$cell_ontology_class)
table(Idents(f))
mouseKidney
mouseBrain
humanPBMC
saveRDS(mouseLiver, "mouseLiver.RDS")
saveRDS(mouseKidney, "mouseKidney.RDS")
mouseFat <- createRFModel(f)
saveRDS(mouseFat, "mouseFat.RDS")
h1 <- load("facs_Heart_seurat_tiss.Robj")
h1 <- UpdateSeuratObject(tiss)
h2 <- load("droplet_Heart_and_Aorta_seurat_tiss.Robj")
h2 <- UpdateSeuratObject(tiss)
h <- merge(h1, y=h2)
Idents(h) <- h$cell_ontology_class
table(Idents(h))
View(k)
mouseHeart <- createRFModel(h)
m1 <- load("droplet_Limb_Muscle_seurat.tiss.Robj")
m1<- load("droplet_Limb_Muscle_seurat_tiss.Robj")
m1 <- UpdateSeuratObject(tiss)
m2 <- load("facs_Limb_Muscle_seurat_tiss.Robj")
m2 <- UpdateSeuratObject(tiss)
m <- merge(m1, y=m2)
m
Idents(m) <- m$cell_ontology_class
table(Idents(m))
mouseMuscle <- createRFModel(m)
saveRDS(mouseFat, "mouseFat.RDS")
saveRDS(mouseMuscle, "mouseMuscle.RDS")
saveRDS(mouseHeart, "mouseHeart.RDS")
s <- load("facs_Skin_seurat_tiss.Robj")
s <- UpdateSeuratObject(tiss)
Idents(s) <- s$cell_ontology_class
table(Idents(s))
mouseSkin <- createRFModel(s)
saveRDS(mouseSkin, "mouseSkin.RDS")
library(devtools)
mouseBrain <- readRDS("rfmodel.RDS")
mouseBrain
setwd("~/Desktop/rfca")
use_data(mouseBrain, mouseMuscle, mouseKidney, mouseLiver, mouseHeart)
use_date(mouseBrain, mouseMuscle, mouseKidney, mouseLiver, mouseHeart, internal = TRUE)
use_data(mouseBrain, mouseMuscle, mouseKidney, mouseHeart, mouseLiver, internal = TRUE)
document()
R_MAX_VSIZE
rm(mouseFat)
rm(mouseSkin)
rm(f, m, m1, m2, l, l1, l2, k, k1, k2, tiss)
rm(h, h1, h2)
document()
rm(list = c("mouseBrain", "mouseHeart", "mouseKidney", "mouseLiver", "mouseMuscle"))
rm(s)
document()
build_readme()
library(pkgdown)
build_site()
build_readme()
cellMarkerPlots <- function(seuratObj, geneList = gsl, pt.size = 0.3, label = TRUE, label.size = 1, repel = FALSE, combine = TRUE){
for (name in names(geneList)) {
log2_norm_umi <- GetAssayData(seuratObj)
log2_norm_umi_selected <- log2_norm_umi[rownames(log2_norm_umi) %in% geneList[[name]], ]
averageScore <- colMeans(as.array(log2_norm_umi_selected))
seuratObj<- AddMetaData(seuratObj, col.name = name, metadata = averageScore)
print(paste0("Calculating average expression of genes in ", name, " list."))
}
plottingInputs <- c(pt.size, label, label.size, repel, combine)
fPlot <- FeaturePlot(seuratObj, names(geneList), pt.size = plottinInputs[1], label = plottingInputs[2], label.size = plottingInputs[3], repel = plottingInputs[4], combine = plottingInputs[5])
return(fPlot)
}
myRandomForestModel <- createRFModel(exampleSeuratObjectLabelled)
markerGeneList <- createGeneLists(myRandomForestModel)
myPlot <- cellMarkerPlots(exampleSeuratObjectLabelled, geneList = markerGeneList)
cellMarkerPlots <- function(seuratObj, geneList = gsl, pt.size = 0.3, label = TRUE, label.size = 1, repel = FALSE, combine = TRUE){
for (name in names(geneList)) {
log2_norm_umi <- GetAssayData(seuratObj)
log2_norm_umi_selected <- log2_norm_umi[rownames(log2_norm_umi) %in% geneList[[name]], ]
averageScore <- colMeans(as.array(log2_norm_umi_selected))
seuratObj<- AddMetaData(seuratObj, col.name = name, metadata = averageScore)
print(paste0("Calculating average expression of genes in ", name, " list."))
}
plottingInputs <- c(pt.size, label, label.size, repel, combine)
fPlot <- FeaturePlot(seuratObj, names(geneList), pt.size = plottingInputs[1], label = plottingInputs[2], label.size = plottingInputs[3], repel = plottingInputs[4], combine = plottingInputs[5])
return(fPlot)
}
myPlot <- cellMarkerPlots(exampleSeuratObjectLabelled, geneList = markerGeneList)
myPlot
cellMarkerPlots <- function(seuratObj, geneList = gsl, pt.size = 0.3, label = TRUE, label.size = 3, repel = FALSE, combine = TRUE){
for (name in names(geneList)) {
log2_norm_umi <- GetAssayData(seuratObj)
log2_norm_umi_selected <- log2_norm_umi[rownames(log2_norm_umi) %in% geneList[[name]], ]
averageScore <- colMeans(as.array(log2_norm_umi_selected))
seuratObj<- AddMetaData(seuratObj, col.name = name, metadata = averageScore)
print(paste0("Calculating average expression of genes in ", name, " list."))
}
plottingInputs <- c(pt.size, label, label.size, repel, combine)
fPlot <- FeaturePlot(seuratObj, names(geneList), pt.size = plottingInputs[1], label = plottingInputs[2], label.size = plottingInputs[3], repel = plottingInputs[4], combine = plottingInputs[5])
return(fPlot)
}
myPlot <- cellMarkerPlots(exampleSeuratObjectLabelled, geneList = markerGeneList)
myPlot
autoLabelledSeuratObject <- predictCells(exampleSeuratObjectUnlabelled, myRandomForestModel)
document()
rm(list = c("cellMarkerPlots"))
document()
build_readme()
.Last.error.trace
document()
mouseBrain <- readRDS("mouseBrain.RDS")
setwd("~/Desktop")
mouseBrain <- readRDS('mouseBrain.RDS')
mouseBrain <- readRDS("rfmodel.RDS")
mouseLiver <- readRDS("mouseLiver.RDS")
mouseKidney <- readRDS("mouseKidney.RDS")
use_data(mouseBrain, mouseKidney, mouseLiver, internal = TRUE)
rm(c('mouseBrain', 'mouseKidney', 'mouseLiver'))
rm("mouseBrain")
rm("mouseLiver")
rm("mouseKidney")
rm("myRandomForestModel")
rm(myPlot)
rm(autoLabelledSeuratObject)
rm(markerGeneList)
mouseBrain <- readRDS('rfmodel.RDS')
use_data(mouseBrain, internal = TRUE)
mouseLiver <- readRDS("mouseLiver.RDS")
use_data(mouseBrain, mouseLiver, internal = TRUE)
library(Seurat)
pbmc.data <- Read10X(data.dir = "hg19")
pbmc <- CreateSeuratObject(counts = pbmc.data, project = "pbmc3k", min.cells = 3, min.features = 200)
pbmc
pbmc[["percent.mt"]] <- PercentageFeatureSet(pbmc, pattern = "^MT-")
pbmc <- subset(pbmc, subset = nFeature_RNA > 200 & nFeature_RNA < 2500 & percent.mt < 5)
pbmc <- NormalizeData(pbmc, normalization.method = "LogNormalize", scale.factor = 10000)
pbmc <- NormalizeData(pbmc)
pbmc <- FindVariableFeatures(pbmc, selection.method = "vst", nfeatures = 2000)
all.genes <- rownames(pbmc)
pbmc <- ScaleData(pbmc, features = all.genes)
pbmc <- RunPCA(pbmc, features = VariableFeatures(object = pbmc))
pbmc <- FindNeighbors(pbmc, dims = 1:10)
pbmc <- FindClusters(pbmc, resolution = 0.5)
pbmc <- RunUMAP(pbmc, dims = 1:10)
new.cluster.ids <- c("Tcells", "Tcells", "Monocytes", "Bcells", "Tcells", "Monocytes",
"NKcells", "DC", "Platelets")
names(new.cluster.ids) <- levels(pbmc)
pbmc <- RenameIdents(pbmc, new.cluster.ids)
DimPlot(pbmc, reduction = "umap", label = TRUE, pt.size = 0.5) + NoLegend()
library(rfca)
humanPBMC <- createRFModel(pbmc)
saveRDS(humanPBMC, "humanPBMC.RDS")
mouseMuscle <- readRDS("mouseMuscle.RDS")
use_data(mouseBrain, humanPBMC, mouseLiver, mouseMuscle, internal = TRUE)
features <- FindVariableFeatures(pbmc, selection.method = "vst", nfeatures = nfeatures)
features <- FindVariableFeatures(pbmc, selection.method = "vst", nfeatures = 200)
topfeatures <- VariableFeatures(features)
topfeaturesedited <- make.names(topfeatures)
topfeaturescleaned <- intersect(topfeatures, topfeaturesedited)
matrix <- as.matrix(GetAssayData(pbmc, slot = "counts"))
m <- subset(matrix, rownames(matrix) %in% topfeaturescleaned)
m <- t(m)
table <- as.data.frame(as.matrix(Idents(pbmc)))
merged <- merge(m, table, by = "row.names", all = TRUE)
merged$V1 <- as.factor(merged$V1)
merged$"Row.names" <- merged$"row.names" <- NULL
rfmodel <- randomForest(V1 ~ ., data=merged, importance=TRUE, proximity=TRUE, ntree = 300)
rfmodel
rfmodel <- randomForest(V1 ~ ., data=merged, importance=TRUE, proximity=TRUE, ntree = 250)
rfmodel
rfmodel <- randomForest(V1 ~ ., data=merged, importance=TRUE, proximity=TRUE, ntree = 200)
rfmodel
saveRDS(rfmodel, "humanPBMC2.RDS")
library(Seurat)