zktuong / ktplots

Some tools for plotting single-cell data
https://zktuong.github.io/ktplots/
MIT License
162 stars 31 forks source link

Warning: ‘>’ not meaningful for factorsError in if (any(lr_interactions[, 3] > 0)) { : missing value where TRUE/FALSE needed #93

Closed zehualilab closed 9 months ago

zehualilab commented 9 months ago

Using plot_cpdb2 in cpdb V5. Thank you for any help!

zktuong commented 9 months ago

Hi i need your full code and error trace to be able to help.

zehualilab commented 9 months ago

I used cellphonedb V 5.0.0 following the standard protocol: deconvoluted, means, pvalues, significant_means = cpdb_statistical_analysis_method.call( cpdb_file_path = cpdb_file_path, # mandatory: CellPhoneDB database zip file. meta_file_path = meta_file_path, # mandatory: tsv file defining barcodes to cell label. counts_file_path = counts_file_path, # mandatory: normalized count matrix. counts_data = 'hgnc_symbol', # defines the gene annotation in counts matrix. iterations = 1000, # denotes the number of shufflings performed in the analysis. threshold = 0.1, # defines the min % of cells expressing a gene for this to be employed in the analysis. threads = 32, # number of threads to use in the analysis. debug_seed = 42, # debug randome seed. To disable >=0. result_precision = 3, # Sets the rounding for the mean values in significan_means. pvalue = 0.05, # P-value threshold to employ for significance. subsampling = False, # To enable subsampling the data (geometri sketching). subsampling_log = False, # (mandatory) enable subsampling log1p for non log-transformed data inputs. subsampling_num_pc = 100, # Number of componets to subsample via geometric skectching (dafault: 100). subsampling_num_cells = 1000, # Number of cells to subsample (integer) (default: 1/3 of the dataset). separator = '|', # Sets the string to employ to separate cells in the results dataframes "cellA|CellB". debug = False, # Saves all intermediate tables employed during the analysis in pkl format. output_path = out_path, # Path to save results. output_suffix = None # Replaces the timestamp in the output files by a user defined string in the (default: None). )

plot_cpdb2(cell_type1 = 'T', cell_type2 = '.', scdata = sce, celltype_key = 'cluster', # column name where the cell ids are located in the metadata means = means, pvals = pvals, deconvoluted = decon, # new options from here on specific to plot_cpdb2 desiredInteractions = list( c('T', 'B'), c('B', 'T')), interaction_grouping = interaction_annotation, edge_group_colors = c( "Activating" = "#e15759", "Chemotaxis" = "#59a14f", "Inhibitory" = "#4e79a7", "Intracellular trafficking" = "#9c755f", "DC_development" = "#B07aa1", "Unknown" = "#e7e7e7" ), node_group_colors = c( "T" = "red", "B" = "blue"), keep_significant_only = T, standard_scale = T, remove_self = T )

interaction_annotation is from data(kidney_immune)

The same code worked out 2 months ago with cpdb V4 and the ktplot version at that time. I could not reproduce after updating this two packages.

WeberKang commented 9 months ago

I have the same problem,you can edit(plot_cpdb3) add lr_interactions[, 3] <- as.character(lr_interactions[, 3]) like this image

zktuong commented 9 months ago

hi both, there is a preliminary fix at #95

to use it, do:

devtools::install_github("zktuong/ktplots", ref = "fix-incorrect-column-usage")