Skip to content

Latest commit

 

History

History
executable file
·
170 lines (167 loc) · 18.4 KB

README.md

File metadata and controls

executable file
·
170 lines (167 loc) · 18.4 KB

shared_seurat_scripts

This is the collection Shared functions used in many scripts

Function list

  • Pulled 7/1/2022 using grep -rE '^\w+ *= *function\(' . in shell
function_seurat_transfer_meta_assay.R:AddMetaAssayToObjList = function(obj_list, predition_list, assay_name='new')
function_seurat_transfer_meta_assay.R:AddMetaAssayListToMergedObj = function(merged_obj, predition_list, assay_name='new')
function_seurat_transfer_meta_assay.R:CleanCellName = function(prediction)
function_seurat_transfer_meta_assay.R:GetMaxCell = function(clean_prediction, new_name)
function_seurat_transfer_meta_assay.R:CreateCleanAssay = function(clean_prediction)
function_seurat_transfer_meta_assay.R:AddMultipleMeta = function(obj, ...)
function_seurat_transfer_meta_assay.R:MakeMergedPredictionMatrix = function(prediction_list, sample_names)
function_spatial_plot_helper.R:SpatialDimPlotOrganizedList = function(obj, plot_meta,  nrow = 3, rainbow_col =T, hide_image=F)
function_spatial_plot_helper.R:SpatialFeaturePlotPlus = function(obj, features, images, expression_ref_obj, sample_labels, pt.size.factors, feature_position = 'column', image.alpha = 0, stroke=NA, color_palette = 'SpatialColor', assemble=T, ...)
function_spatial_plot_helper.R:SpatialFeaturePlotPlusSampleAsRow = function(obj, features, images, sample_labels, pt.size.factors, exp_lows, exp_highs, col_palette, assemble_col=T, ...)
function_spatial_plot_helper.R:SpatialFeaturePlotPlusFeatureAsRow = function(obj, features, images, sample_labels, pt.size.factors, exp_lows, exp_highs, col_palette, assemble_row=T, ...)
function_RCTD_helper_v2.R:RCTD_obj2list = function(RCTD_result_obj)
function_RCTD_helper_v2.R:getRCTD_result = function(st_obj, snrna_obj, colu_cell_type='cell_type_Abbr', mode ='full',cell_count_filter = 25)
function_RCTD_helper_v2.R:RCTD2assay = function(x, meta, ...)
function_RCTD_helper_v2.R:ratio2meta = function(x, col_name= 'RCTD')
function_RCTD_helper_v2.R:RCTD2meta = function(x, ...)
function_RCTD_helper_v2.R:fix_cellname = function(names) str_replace_all(names,'-','_')}
function_RCTD_helper_v2.R:fix_cellname_mtx = function(obj, mode = c('column','row'))
function_RCTD_helper_v2.R:integrate_RCTDassay_mtx = function(orig_mtx, new_mtx, fix_name = T)
function_RCTD_helper_v2.R:integrate_RCTDmeta = function(orig_meta, new_meta, target_cols, create_new_col=T)
function_RCTD_helper_v2.R:order_mtx_ids = function(mtx, ordered_ids)
function_RCTD_helper_v2.R:integrate_RCTDmeta_to_obj = function(obj, new_meta)
function_seurat_janitor.R:fix_median_umi = function(SCTModel_obj)
function_seurat_janitor.R:clean_seurat_obj_list = function(obj_list, attirbute_to_check)
function_seurat_janitor.R:clean_seurat_SCTModel_list = function(sct_model_list)
function_seurat_janitor.R:clean_seurat_image_list = function(img_list)
function_seurat_janitor.R:FixSeuratSCT = function(obj)
function_seurat_janitor.R:FixSeuratImage = function(obj)
function_seurat_janitor.R:fix_seurat_SCT = function(obj)
function_seurat_janitor.R:fix_seurat_image = function(obj)
function_seurat_pipeline_v1.R:spatial_initial_process = function(obj, pca_npcs=30, resolution=0.5, verbose=T, no_normalization =F, method = 'SCT' )
function_seurat_pipeline_v1.R:spatial_integration = function(st_objs, integration_mode='merge', run_cluster=T, future_worker=50, future_max_gb=40, 
function_seurat_pipeline_v1.R:seurat_cell_type_transfer = function(st_obj, reference_obj, ref_cell_type_col_name='cell_type', 
function_seurat_pipeline_v1.R:getDominantAssignment=function(obj, assay_name)
function_colors.R:ExtendColorVector = function(color_vector, target_class, reduce = T, palettes_use = 'glasbey', palette_method = c('Seurat','RColorBrewer'), randomize = F)
function_colors.R:GetRColorBrewerQual = function(as_list = F)
function_st_distance_plot.R:get_distance_mtx = function(coord_df, normalize = T)
function_st_distance_plot.R:get_neighbor_id_list = function(distance_mtx, size = 1)
function_st_distance_plot.R:get_neighbor_id = function(quary_id, neighbor_list)
function_ST_summary_plot.R:make_ST_summary_plot = function(folder_path, out_path, plot_title, replace_exist = F, seurat_out_path)
function_spatial_decon_wrapper.R:st_decon_seurat = function(st_merge, snrna, st_transfer_assay, st_transfer_col, sn_cell_type_col)
function_spatial_decon_wrapper.R:st_decon_RCTD = function(st_merge, snrna, st_RCTD_assay, st_RCTD_col, sn_cell_type_col, min_cell_type_count=25, st_RCTD_obj, doublet_mode = 'multi')
function_spatial_decon_wrapper.R:st_decon_prefly_check = function(st_merge, snrna, sn_cell_type_col)
function_spatial_decon_wrapper.R:st_decon_saving = function(st_merge, save_type, st_out_obj)
function_spatial_decon_wrapper.R:st_decon_wrapper = function(st_merge, snrna, snrna_assay_name = "snrna", sn_cell_type_col, st_run_version = "v1", save_type = 'rds',
function_spatial_decon_wrapper.R:st_decon_wrapper_paired = function(st_merge, snrna, snrna_assay_name = "snrna", sn_cell_type_col, st_run_version = "v1", save_type = 'rds',
function_spacexr_helper_v2.R:RCTD_obj2list = function(RCTD_result_obj)
function_spacexr_helper_v2.R:getRCTD_result = function(st_obj, snrna_obj, colu_cell_type='cell_type_Abbr', mode ='full',cell_count_filter = 25, reduce_size = F)
function_spacexr_helper_v2.R:RCTD2assay = function(x, meta, ...)
function_spacexr_helper_v2.R:ratio2meta = function(x, col_name= 'RCTD')
function_spacexr_helper_v2.R:RCTD2meta = function(x, ...)
function_spacexr_helper_v2.R:fix_cellname = function(names) str_replace_all(names,'-','_')}
function_spacexr_helper_v2.R:fix_cellname_mtx = function(obj, mode = c('column','row'))
function_spacexr_helper_v2.R:integrate_RCTDassay_mtx = function(orig_mtx, new_mtx, fix_name = T)
function_spacexr_helper_v2.R:integrate_RCTDmeta = function(orig_meta, new_meta, target_cols, create_new_col=T)
function_spacexr_helper_v2.R:order_mtx_ids = function(mtx, ordered_ids)
function_spacexr_helper_v2.R:integrate_RCTDmeta_to_obj = function(obj, new_meta)
Kidne.ipynb_checkpointfunction_Kidney_STDim_v5-checkpoint.R:make_NMK_STdim_plot = function(st_merge, st_male, st_female, group.by, male_sm_set, male_sm_set_ptsize, female_sm_set, female_sm_set_ptsize,color_palette='Seurat')
Kidne.ipynb_checkpointfunction_Kidney_STDim_v5-checkpoint.R:make_AKI_plot = function(st_merge, st_aki, gene_to_plot, aki_male_set, aki_male_set_ptsize, aki_male_set_labels, aki_female_set, aki_female_set_ptsize)
Kidne.ipynb_checkpointfunction_Kidney_STDim_v5-checkpoint.R:plot_NMK_AKI  = function(st_merge, st_male, st_female, st_aki, gene_to_plot, title ="", subtitle="", plot_group)
Kidne.ipynb_checkpointfunction_Kidney_STDim_v5-checkpoint.R:make_expression_plot = function(st_merge, gene_of_interest, split_by, split_filter, error_bar=F)
Kidne.ipynb_checkpointfunction_Kidney_STDim_v5-checkpoint.R:SpatialDimPlotPlus = function(obj, group.by, images, pt.size.factors, labels, show_image = T, colors = plot_col)
Kidne.ipynb_checkpointfunction_Kidney_STDim_v5-checkpoint.R:nmk_STDim_UMAP_plot = function(st_merge, st_male, st_female, group_by, male_sm_set, male_sm_set_ptsize, female_sm_set, female_sm_set_ptsize, age_labels, plot_colors)
Kidne.ipynb_checkpointfunction_Kidney_STdist_v5-checkpoint.R:make_NMK_plot = function(st_merge, st_male, st_female, gene_to_plot, male_sm_set, male_sm_set_ptsize, female_sm_set, female_sm_set_ptsize)
Kidne.ipynb_checkpointfunction_Kidney_STdist_v5-checkpoint.R:make_AKI_plot = function(st_merge, st_aki, gene_to_plot, aki_male_set, aki_male_set_ptsize, aki_male_set_labels, aki_female_set, aki_female_set_ptsize)
Kidne.ipynb_checkpointfunction_Kidney_STdist_v5-checkpoint.R:plot_NMK_AKI  = function(st_merge, st_male, st_female, st_aki, gene_to_plot, title ="", subtitle="", plot_group)
Kidne.ipynb_checkpointfunction_Kidney_STdist_v5-checkpoint.R:make_expression_plot = function(st_merge, gene_of_interest, split_by, split_filter, error_bar=F)
Kidnefunction_ST_correlation_dot_plot.R:get_all_Agesex_cor_df = function(obj, group_by = 'Age_sex', ...)
Kidnefunction_ST_correlation_dot_plot.R:get_celltype_cor_df = function(obj, ident, group_by = 'Age_sex', features ,assay_name = 'RCTD_doubletRM_v3', test_sample_threshold = 5, complete_matrix =T, cor_method='complete.obs', split_col_by = '_')
Kidnefunction_ST_correlation_dot_plot.R:get_exp_cor_df = function(obj, ident, group_by = 'Age_sex', features ,assay_name = 'SCT', test_sample_threshold = 5, complete_matrix =T, cor_method='complete.obs', split_col_by = '_')
Kidnefunction_ST_correlation_dot_plot.R:get_cor_df = function(obj, ident, group_by = 'Age_sex', features ,assay_name = 'SCT', test_sample_threshold = 5, complete_matrix =T, cor_method='complete.obs', split_col_by = '_')
Kidnefunction_ST_correlation_dot_plot.R:triangle_to_df = function(m, value_name ='corr')
Kidnefunction_ST_correlation_dot_plot.R:matrix2cor_df = function(value_matrix, complete_matrix =T, cor_method='complete.obs')
Kidnefunction_ST_plot_general_v1.R:st_get_expression = function(coord_df, obj, features)
Kidnefunction_ST_plot_general_v1.R:st_get_assay_value = function(coord_df, obj, assay_use, features) # 22021
Kidnefunction_ST_plot_general_v1.R:st_add_meta = function(coord_df, obj, features)
Kidnefunction_ST_plot_general_v1.R:st_get_assay = function(coord_df, exp_df, feature_col, feature_value_col, value_threshold ,top_n)
Kidnefunction_ST_plot_general_v1.R:filter_spots = function(coord_df, meta_df, filter_col, filter_group)
Kidnefunction_ST_plot_general_v1.R:st_scale_and_center = function(df, nodge_x=0, nodge_y=0)
Kidnefunction_ST_plot_general_v1.R:st_rotation = function(coord_df, counter_degree = 90, mirror='none')
Kidnefunction_ST_plot_general_v1.R:st_ggplot = function(coord_df, feature, mode,
Kidnefunction_ST_plot_general_v1.R:st_highlight = function(df, obj, highlight_col, highlight_idents, highlight_alpha = 1, other_alpha = 0.1)
Kidnefunction_ST_plot_general_v1.R:SingleSTDistIdentPlot = function(obj, slice, mode, meta_palette, rotation=0, feature, 
Kidnefunction_ST_plot_general_v1.R:st_proportion_adjust_exp = function(coord_exp_df, obj, assay_name = 'RCTD_doubletRM_v3', highlight_cell_type)
Kidnefunction_ST_plot_general_v1.R:MultipleSTDistIdentPlot = function(obj, images, feature, mode, left_label = '', mirrors, rotates, top_labels, nodges_x, nodges_y, filter_piece_col , filter_piece, xlimits, ylimits, ...)
Kidnefunction_ST_plot_general_v1.R:cell_type_scatterpie = function(obj, slice, cell_type_df, value_threshold=0.1, rotation=0, pie_size=1, xlimit=c(-64,64), ylimit = c(-64,64), palette, use_alpha=T)
Kidnefunction_Kidney_STdist_v5.R:make_NMK_plot = function(st_merge, st_male, st_female, gene_to_plot, male_sm_set, male_sm_set_ptsize, female_sm_set, female_sm_set_ptsize)
Kidnefunction_Kidney_STdist_v5.R:make_AKI_plot = function(st_merge, st_aki, gene_to_plot, aki_male_set, aki_male_set_ptsize, aki_male_set_labels, aki_female_set, aki_female_set_ptsize)
Kidnefunction_Kidney_STdist_v5.R:plot_NMK_AKI  = function(st_merge, st_male, st_female, st_aki, gene_to_plot, title ="", subtitle="", plot_group)
Kidnefunction_Kidney_STdist_v5.R:make_expression_plot = function(st_merge, gene_of_interest, split_by, split_filter, error_bar=F)
Kidnefunction_plots_v1.R:line_plot_list = function(obj, features, ...)
Kidnefunction_plots_v1.R:line_plot =  function(obj, feature, group_by, idents, split_by, split_idents, assay='SCT', x_axis = 'Age')
Kidnefunction_load_AKIobjs_10252021.r:load_nmk_st = function()
Kidnefunction_load_AKIobjs_10252021.r:loadakiobj = function(type = c('rna','atac','st'))
Kidnefunction_load_AKIobjs_10252021.r:loadakisn = function()
Kidnefunction_load_AKIobjs_10252021.r:loadakiST = function()
Kidnefunction_load_AKIobjs_10252021.r:loadakiatac = function()
Kidnefunction_ST_NMKAKI_plots.R:make_nmk_mf_st_plot = function(...)
Kidnefunction_ST_NMKAKI_plots.R:STDistAKIPlots = function(obj, features, ...)
Kidnefunction_ST_NMKAKI_plots.R:STDistNMKPlots = function(obj, features, ...)
Kidnefunction_ST_NMKAKI_plots.R:STDistPlots = function(obj, features, mode = c('AKI','NMK'), pt_size=1.8, ...)
Kidnefunction_ST_NMKAKI_plots.R:STDistPlotsBoth = function(st_nmk, st_aki, features, pt_size=1.8, combine=T, ...)
Kidnefunction_ST_NMKAKI_plots.R:getSTPlotSize = function(type=c('NMK','AKI','Both'))
Kidnefunction_ST_NMKAKI_plots.R:PlotSTJupyter = function(p, type=c('NMK','AKI','Both'))
Kidnefunction_ST_NMKAKI_plots.R:PlotSTlistJupyter = function(plist, type)
Kidnefunction_ST_NMKAKI_plots.R:SaveSTPlots = function(plist, type=c('NMK','AKI','Both'), path)
Kidnefunction_ST_NMKAKI_plots.R:getSTExpRange = function(obj, imgs, feature, mode, assay_use)
Kidnefunction_ST_NMKAKI_plots.R:STDistPlot_AKI = function(obj, feature, pt_size=1.6, images_m, images_f, xlimits_m, ylimits_m, xlimits_f, ylimits_f, 
Kidnefunction_ST_NMKAKI_plots.R:STDistPlot_NMK_MF = function(obj, feature, pt_size=1.6, images_m, images_f, xlimits_m, ylimits_m, xlimits_f, ylimits_f, 
Kidnefunction_ST_NMKAKI_plots.R:make_nmk_multiple_st_plot = function(obj, features, ...)
Kidnefunction_STblendplot_v1.R:STBlendPlot = function(st, feature_pairs, images=1, show_histology=F, wrap_slices=T,...)
Kidnefunction_STblendplot_v1.R:SThistology = function(st, images)
Kidnefunction_STblendplot_v1.R:MultiFeatureSTBlendPlot = function(st, feature_pairs, images=1, show_blend_only, show_histology=F, wrap_slices=T,...)
Kidnefunction_STblendplot_v1.R:MultiImageSTBlendPlot = function(st, feature_pair, images=1, combine=F, assay = 'SCT', show_blend_only, show_histology=F, 
Kidnefunction_STblendplot_v1.R:SingleSTBlendPlot = function(st, features, combine = T, assay = 'SCT', image, show_blend_legend =T,
Kidnefunction_STblendplot_v1.R:normalize_01 = function(x, to_round=F, to_int=F) # Normalize a vector of number to 0 to 1 range
Kidnefunction_STblendplot_v1.R:blendExpression_v2 = function(exp_df, features)
Kidnefunction_STblendplot_v1.R:adjust_data = function(data, cols)
Kidnefunction_Kidney_STDim_v5.R:make_NMK_STdim_plot = function(st_merge, st_male, st_female, group.by, male_sm_set, male_sm_set_ptsize, female_sm_set, female_sm_set_ptsize,color_palette='Seurat')
Kidnefunction_Kidney_STDim_v5.R:make_AKI_plot = function(st_merge, st_aki, gene_to_plot, aki_male_set, aki_male_set_ptsize, aki_male_set_labels, aki_female_set, aki_female_set_ptsize)
Kidnefunction_Kidney_STDim_v5.R:plot_NMK_AKI  = function(st_merge, st_male, st_female, st_aki, gene_to_plot, title ="", subtitle="", plot_group)
Kidnefunction_Kidney_STDim_v5.R:make_expression_plot = function(st_merge, gene_of_interest, split_by, split_filter, error_bar=F)
Kidnefunction_Kidney_STDim_v5.R:SpatialDimPlotPlus = function(obj, group.by, images, pt.size.factors, labels, show_image = T, colors = plot_col)
Kidnefunction_Kidney_STDim_v5.R:nmk_STDim_UMAP_plot = function(st_merge, st_male, st_female, group_by, male_sm_set, male_sm_set_ptsize, female_sm_set, female_sm_set_ptsize, age_labels, plot_colors)
function_dotplot_ruiyang.R:helper_cluster_expression_plot = function(to_plot, exprs.to.plot, dot.color.range, facet.order, y.axis.order, rotate_title)
function_dotplot_ruiyang.R:helper_check_celltype_marker = function(celltype_markers)
function_dotplot_ruiyang.R:helper_filter_cell_marker = function(obj, celltype_markers, min_marker=1)
function_dotplot_ruiyang.R:getCellTypeMarkerAssay = function(obj, celltype_marker=NULL, new_assay_name="CellTypeScore", min_marker = 1)
function_seurat_helper.R:get_rainbow_col = function(n=10, start=0.2, end =1  )
function_seurat_helper.R:spatial_feature_unify_fill_scale = function(plot_obj_list, st_obj,  markers)
function_seurat_helper.R:rotate_coord = function(coord,rotate, x_shift=0, y_shift=0) # Flip x and y, then turn new x negative
function_seurat_helper.R:rotate_spatial_slice = function(obj, slice='slice1', rotate, x_shift=0, y_shift=0)
function_seurat_helper.R:getDominantAssignment=function(obj, assay_name)
function_seurat_helper.R:helper_getMarkerScore = function(obj, features)
function_seurat_helper.R:getAllMarkerScore = function(obj, marker_df)
function_ST_distance_pattern_analysis_v1.R:get_coord_meta_df = function(st, slice, cell_ids, column_include)
function_ST_distance_pattern_analysis_v1.R:get_distance_mtx = function(coord_df, normalize = T)
function_ST_distance_pattern_analysis_v1.R:get_neighbor_id_list = function(distance_mtx, size = 1)
function_ST_distance_pattern_analysis_v1.R:get_neighbor_id = function(quary_id, neighbor_list)
function_ST_distance_pattern_analysis_v1.R:get_source_spots = function(source_spots, neighbor_spots, distance_mtx, include_source_spots=T)
function_ST_distance_pattern_analysis_v1.R:add_source_meta = function(meta_df, source_dist_df, meta_columns = c('histology'), add_column_name = 'source')
function_ST_distance_pattern_analysis_v1.R:get_neighborhood_df = function(source_spots, neighboor_spots, distance_mtx, include_source_spots=T,
function_ST_distance_pattern_analysis_v1.R:add_neighboor_features = function(st_obj, neighborhood_df, features, assay)
function_ST_distance_pattern_analysis_v1.R:FindNeighborhoodDE = function(obj, neighborhood_df, source_range = 0,
function_ST_distance_pattern_analysis_v1.R:SweepNeighborhoodDE = function(obj, neighborhood_df, source_range=0, sweep_range=3:5, sweep_size=1, sweep_overlap =T)
function_ST_distance_pattern_analysis_v1.R:GetSweepNeighborhoodDEJaccardScore = function(neighborhood_de_sweep_df, fdr_cutoff = 0.05, complete_table =T)
function_ST_distance_pattern_analysis_v1.R:plot_spatial_neighboor_feature = function(neighborhood_df, 
function_ST_distance_pattern_analysis_v1.R:plot_spatial_neighboor_distance = function(neighborhood_gene_df, 
function_ST_distance_pattern_analysis_v1.R:plot_spatial_neighboor_features = function(neighborhood_gene_df, 
function_ST_distance_pattern_analysis_v1.R:plot_feature_distance_curve = function(neighborhood_feature_df,
function_spatial_neighbhood.R:GetNeighborSpots = function(st, target_ids, distance = 4, min_distance = 0, slice, include_target = F)
function_spatial_neighbhood.R:PlotCellRatioBarplotPerArea = function(obj, assay_name, area_list, cell_include, 
function_spatial_neighbhood.R:PlotBarplotCellRatioByIdent = function(obj, assay_name, group.by, ident_include, cell_include, 
function_spatial_neighbhood.R:GetDiscreteColors = function(method = c('RColorBrewer','Seurat'), n)
function_spatial_neighbhood.R:GetAllBrewerColor = function(palette_type = 'qual')
function_spatial_neighbhood.R:GetSpotFromIdent = function(obj, group.by, ident_include)
function_spatial_neighbhood.R:GetCellRatioPerArea = function(obj, assay_name, area_list, cell_include, pivot = T)
function_spatial_neighbhood.R:CellRatioBarplotPerArea = function(df, cell_palette, label =T, label_threshold = 0.05, label_col = 'gray90', show_percent = T)
pipline_spacexr_RCTD_transfer.R:obj_loader = function(obj_path)
function_checkargument.R:CheckArgument = function(fun, arglist)
function_splitseuratobj.R:SplitSeuratObj = function(obj, split.by, use_future = F)