Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
custom
Rossari_SciTraMed_2025
Commits
b6921cde
Commit
b6921cde
authored
Feb 26, 2025
by
Stefano Beretta
Browse files
Upload New File
parent
273aeed9
Changes
1
Show whitespace changes
Inline
Side-by-side
SCENIC_CART/export_loom.R
0 → 100644
View file @
b6921cde
library
(
Seurat
)
library
(
SCENIC
)
library
(
SCopeLoomR
)
library
(
dplyr
)
args
<-
commandArgs
(
trailingOnly
=
TRUE
)
# Input Seurat RDS file
in_rds
<-
args
[
1
]
# Output
out_loom
<-
args
[
2
]
in_obj
<-
readRDS
(
in_rds
)
assay_name
<-
"RNA"
if
(
!
assay_name
%in%
names
(
in_obj
@
assays
))
{
assay_name
<-
names
(
in_obj
@
assays
)[
1
]
print
(
"'RNA' assay not found!"
)
print
(
paste0
(
"Using "
,
assay_name
,
" as assay."
))
}
umap_vars
<-
grep
(
"umap"
,
names
(
in_obj
@
reductions
),
value
=
T
)
umap_name
<-
grep
(
"harmony"
,
umap_vars
,
value
=
T
)
if
(
length
(
umap_name
==
0
))
{
umap_name
<-
umap_vars
[
1
]
}
umap
<-
as.data.frame
(
in_obj
@
reductions
[[
umap_name
]]
@
cell.embeddings
)
colnames
(
umap
)
<-
c
(
"X"
,
"Y"
)
cm
<-
in_obj
@
assays
[[
assay_name
]]
cm
<-
as.matrix
(
cm
$
counts
)
loom
<-
build_loom
(
file.name
=
out_loom
,
dgem
=
cm
,
default.embedding
=
umap
,
default.embedding.name
=
"umap"
)
loom
<-
add_cell_annotation
(
loom
=
loom
,
cellAnnotation
=
in_obj
@
meta.data
)
close_loom
(
loom
=
loom
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment