Skip to content

Commit 791f755

Browse files
authored
Update LineageFunctions
1 parent 13175b7 commit 791f755

1 file changed

Lines changed: 1 addition & 90 deletions

File tree

LineageFunctions.R

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -76,55 +76,8 @@ plotAMI<-function(AMIlist,plotcolours,pname){
7676
print(AMIplot)
7777
dev.off()
7878
}
79-
# Parameters
80-
global <- list(
81-
n_genes = 'all', # set to 'all' to use all protein coding genes found in both datasets
82-
umap_n_neighbors = 10, # num nearest neighbors used to create UMAP plot
83-
umap_min_dist = 0.5, # min distance used to create UMAP plot
84-
mnn_k_CL = 5, # number of nearest neighbors of tumors in the cell line data
85-
mnn_k_tumor = 50, # number of nearest neighbors of cell lines in the tumor data
86-
top_DE_genes_per = 1000, # differentially expressed genes with a rank better than this is in the cell line or tumor data
87-
# are used to identify mutual nearest neighbors in the MNN alignment step
88-
remove_cPCA_dims = c(1,2,3,4), # which cPCA dimensions to regress out of the data
89-
distance_metric = 'euclidean', # distance metric used for the UMAP projection
90-
mod_clust_res = 5, # resolution parameter used for clustering the data
91-
mnn_ndist = 3, # ndist parameter used for MNN
92-
n_PC_dims = 70, # number of PCs to use for dimensionality reduction
93-
reduction.use = 'umap', # 2D projection used for plotting
94-
fast_cPCA = 10 # to run fast cPCA (approximate the cPCA eigenvectors instead of calculating all) set this to a value >= 4
95-
)
9679

97-
create_Seurat_object <- function(exp_mat, ann, type = NULL) {
98-
#exp_mat should be genes x cell lines
99-
seu_obj <- Seurat::CreateSeuratObject(exp_mat,
100-
min.cells = 0,
101-
min.features = 0,
102-
meta.data = ann %>%
103-
magrittr::set_rownames(ann$sampleID))
104-
if(!is.null(type)) {
105-
seu_obj@meta.data$type <- type
106-
}
107-
# mean center the data, important for PCA
108-
seu_obj <- Seurat::ScaleData(seu_obj, features = rownames(Seurat::GetAssayData(seu_obj)), do.scale = F)
109-
110-
seu_obj %<>% Seurat::RunPCA(assay='RNA',
111-
features = rownames(Seurat::GetAssayData(seu_obj)),
112-
npcs = global$n_PC_dims, verbose = F)
113-
114-
seu_obj %<>% Seurat::RunUMAP(assay = 'RNA', dims = 1:global$n_PC_dims,
115-
reduction = 'pca',
116-
n.neighbors = global$umap_n_neighbors,
117-
min.dist = global$umap_min_dist,
118-
metric = global$distance_metric, verbose=F)
119-
umapcoords<-FetchData(seu_obj,vars=c("UMAP_1","UMAP_2"))
120-
return(umapcoords)
121-
}
122-
LineageUMAP<-function(){
123-
CIoutput<-tCI[,TCGAbreast$sampleID]
124-
#assume have data want to use in CIoutput
125-
umapData<-create_Seurat_object(CIoutput,CIannot[CIannot$sampleID%in%TCGAbreast$sampleID,])
126-
127-
}
80+
12881

12982

13083
classPerfLineage<-function(dataset,qualityTH=Inf,QC=NULL,weights=NULL,geneset=NULL,distmetric="Cor",lineagelabel,withRange=1){
@@ -182,45 +135,3 @@ getLRTgenes<-function(normLRTlist,thresh=200){
182135
glist<-lapply(normLRTlist,function(x) names(x[[3]])[x[[3]]>thresh])
183136
return(unique(unlist(glist)))
184137
}
185-
global <- list(
186-
n_genes = 'all', # set to 'all' to use all protein coding genes found in both datasets
187-
umap_n_neighbors = 10, # num nearest neighbors used to create UMAP plot
188-
umap_min_dist = 0.5, # min distance used to create UMAP plot
189-
mnn_k_CL = 5, # number of nearest neighbors of tumors in the cell line data
190-
mnn_k_tumor = 50, # number of nearest neighbors of cell lines in the tumor data
191-
top_DE_genes_per = 1000, # differentially expressed genes with a rank better than this is in the cell line or tumor data
192-
# are used to identify mutual nearest neighbors in the MNN alignment step
193-
remove_cPCA_dims = c(1,2,3,4), # which cPCA dimensions to regress out of the data
194-
distance_metric = 'euclidean', # distance metric used for the UMAP projection
195-
mod_clust_res = 5, # resolution parameter used for clustering the data
196-
mnn_ndist = 3, # ndist parameter used for MNN
197-
n_PC_dims = 50, # number of PCs to use for dimensionality reduction
198-
reduction.use = 'umap', # 2D projection used for plotting
199-
fast_cPCA = 20 # to run fast cPCA (approximate the cPCA eigenvectors instead of calculating all) set this to a value >= 4
200-
)
201-
create_Seurat_object <- function(exp_mat, ann, type = NULL) {
202-
#exp_mat should be genes x cell lines
203-
seu_obj <- Seurat::CreateSeuratObject(exp_mat,
204-
min.cells = 0,
205-
min.features = 0,
206-
meta.data = ann %>%
207-
magrittr::set_rownames(ann$model_id))
208-
if(!is.null(type)) {
209-
seu_obj@meta.data$type <- type
210-
}
211-
# mean center the data, important for PCA
212-
seu_obj <- Seurat::ScaleData(seu_obj, features = rownames(Seurat::GetAssayData(seu_obj)), do.scale = F)
213-
214-
seu_obj %<>% Seurat::RunPCA(assay='RNA',
215-
features = rownames(Seurat::GetAssayData(seu_obj)),
216-
npcs = global$n_PC_dims, verbose = F)
217-
218-
seu_obj %<>% Seurat::RunUMAP(assay = 'RNA', dims = 1:global$n_PC_dims,
219-
reduction = 'pca',
220-
n.neighbors = global$umap_n_neighbors,
221-
min.dist = global$umap_min_dist,
222-
metric = global$distance_metric, verbose=F)
223-
umapcoords<-FetchData(seu_obj,vars=c("UMAP_1","UMAP_2"))
224-
return(umapcoords)
225-
}
226-

0 commit comments

Comments
 (0)