CytoTalk
CytoTalk copied to clipboard
looping for multiple cell types
i have 12 cell types i think this algorithm works with two cell types at a time so for 12 cell types i have to run the 66 times so please guide me in adding the loop while running dir_in <- "C:/Users/prave/Desktop/praveen" lst_scrna <- CytoTalk::read_matrix_folder(dir_in) celltypes = [] results = {} for (i in range(len(celltypes) - 1)) { for (j in range(i+1, len(celltypes))) { type_a = celltypes[i] type_b = celltypes[j] result = CytoTalk::run_cytotalk(lst_scrna, type_a, type_b) results[f"result{i}{j}"] = result } }
Hi, you can try the code below.
dir_in <- "C:/Users/prave/Desktop/praveen"
lst_scrna <- CytoTalk::read_matrix_folder(dir_in)
celltypes <- unique(lst_scrna$cell_types)
for (i in 1:(length(celltypes)-1)) {
for (j in (i+1):length(celltypes)) {
type_a <- celltypes[i]
type_b <- celltypes[j]
Output_FolderName <- paste0(celltypes[i], "_VS_", celltypes[j])
results <- CytoTalk::run_cytotalk(lst_scrna, type_a, type_b, pcg=CytoTalk::pcg_human, lrp=CytoTalk::lrp_human, dir_out=Output_FolderName)
}
}
You will get an output folder for each cell type pair.
Also, note that above code is for scRNA-seq data from human tissues. If your data is from mouse tissues, two parameters should be changed as pcg=CytoTalk::pcg_mouse, lrp=CytoTalk::lrp_mouse
. For details, see ?CytoTalk::run_cytotalk