-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.jl
46 lines (36 loc) · 1.26 KB
/
example.jl
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
import Pkg
Pkg.activate(".") # Activate the project environment in the current directory
Pkg.instantiate() # Install dep pacakges
# Load scLENS
using scLENS
# Device selection for GPU or CPU processing
using CUDA:has_cuda
cur_dev = if has_cuda()
"gpu"
else
"cpu"
end
# Load the compressed CSV file into a dataframe
ndf = scLENS.read_file("data/Z8eq.csv.gz")
# ndf = scLENS.read_file("data/Z8eq.csv.gz",gid_file="gene_dictionary/gene_id.csv")
# Perform data preprocessing
pre_df = scLENS.preprocess(ndf)
# Create an embedding using scLENS
sclens_embedding = scLENS.sclens(pre_df,device_=cur_dev)
scLENS.plot_mpdist(sclens_embedding)
scLENS.plot_stability(sclens_embedding)
# Apply UMAP transformation
scLENS.apply_umap!(sclens_embedding)
panel_1 = scLENS.plot_embedding(sclens_embedding,pre_df.cell)
# Save the PCA results to a CSV file
using CSV
using DataFrames
CSV.write("out/pca.csv",sclens_embedding[:pca_n1])
CSV.write("out/umap.csv",DataFrame(sclens_embedding[:umap],:auto)) # Save the UMAP results to a CSV file
# Save scLENS outcome as anndata
scLENS.save_anndata("out/test_data.h5ad",sclens_embedding)
# the UMAP distribution as an image
using CairoMakie
CairoMakie.activate!(type = "png")
save("out/umap_dist.png", panel_1)
# savefig(panel_1,"out/umap_dist.png")