Commit 42a4bf7a authored by smorabit's avatar smorabit
Browse files

pseudotime tutorial

parent 061f6814
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -83,14 +83,16 @@ PlotModuleTrajectory <- function(
    modules <- GetModules(seurat_obj, wgcna_name=wgcna_name)
    mods <- levels(modules$module)
    mods <- mods[mods!='grey']
    module_colors <- modules %>% dplyr::select(c(module, color)) %>% distinct()
    module_colors <- modules %>% dplyr::select(c(module, color)) %>% dplyr::distinct()
    
    #rownames(module_colors) <- module_colors$module
    mod_colors <- module_colors$color; names(mod_colors) <- module_colors$module

    # merge the MEs with the seurat metadata
    plot_df <- cbind(seurat_obj@meta.data, MEs)
    plot_df <-seurat_obj@meta.data

    print(head(plot_df))

    # loop through each pseudotime trajectory:
    avg_list <- list()
    for(ps_col in pseudotime_col){
@@ -110,6 +112,7 @@ PlotModuleTrajectory <- function(
        avg_list[[ps_col]] <- avg_df
    }


    plot_df <- do.call(rbind, avg_list)

    # plotting a single trajectory (color by module)
+3 −0
Original line number Diff line number Diff line
@@ -458,6 +458,9 @@ dev.off()
# just get the ery lineage 
seurat_ery <- subset(seurat_obj, celltype %in% c("HSC", "MEP", 'Ery'))

seurat_ery <- BinPseudotime(seurat_ery, pseudotime_col='ery_pseudotime', n_bins=c(20))
levels(seurat_ery$ery_pseudotime_bins_20) %>% length

seurat_ery <- BinPseudotime(seurat_ery, pseudotime_col='ery_pseudotime', n_bins=c(5))
bins <- levels(seurat_ery$ery_pseudotime_bins_5)