psupertime icon indicating copy to clipboard operation
psupertime copied to clipboard

error in psupertime_go_analysis

Open mikashin opened this issue 10 months ago • 0 comments

Hi,

I've tested with the supplementary dataset from the package "psupplementary". And I met an error as the below.

go_list = psupertime_go_analysis(psuper_obj, org_mapping='org.Hs.eg.db') clustering genes calculating GO enrichments for 3 clusters: ... Warning messages: 1: In melt(x_data, varnames = c("cell_id", "symbol")) : The melt generic in data.table has been passed a matrix and will attempt to redirect to the relevant reshape2 method; please note that reshape2 is deprecated, and this redirection is now deprecated as well. To continue using melt methods from reshape2 while both libraries are attached, e.g. melt.list, you can prepend the namespace like reshape2::melt(x_data). In the next version, this warning will become an error. 2: In melt(x_data, varnames = c("cell_id", "symbol")) : The melt generic in data.table has been passed a matrix and will attempt to redirect to the relevant reshape2 method; please note that reshape2 is deprecated, and this redirection is now deprecated as well. To continue using melt methods from reshape2 while both libraries are attached, e.g. melt.list, you can prepend the namespace like reshape2::melt(x_data). In the next version, this warning will become an error.

When I tried with our own datset, other errors showed up at this function again;

go_list = psupertime_go_analysis(psuper_obj,org_mapping='org.Hs.eg.db') clustering genes Error in psupertime_go_analysis(psuper_obj, org_mapping = "org.Hs.eg.db") : object 'k' not found

In case you want to see the script I use, I leave the codes here. Hope there is a simple solution for the error!

get data

message('loading acinar cell SCE object') tag = 'aging_acinar' label_name = 'Donor age\n(years)' data(acinar_sce) acinar_sce #SCE format

restrict to highly variable genes

message('identifying highly variable genes') hvg_params = list(hvg_cutoff=0.1, bio_cutoff=0.5, span=0.1) sel_genes = psupertime:::.calc_hvg_genes(acinar_sce, hvg_params) acinar_hvg = acinar_sce[sel_genes, ] acinar_hvg

---- fig.show='hold', fig.height=5, fig.width=6, fig.cap="UMAP dimensionality reduction"----

check whether can use umap

if ( !requireNamespace("umap", quietly=TRUE) ) { message('umap not installed; not doing clustering') return() } library('umap')

calc and plot umap

message('projecting using UMAP') x = t(SummarizedExperiment::assay(acinar_hvg, 'logcounts')) wellKey_vector = SingleCellExperiment::colData(acinar_hvg)$wellKey label_vector = factor(SingleCellExperiment::colData(acinar_hvg)[['donor_age']]) proj_umap = psupplementary:::calc_umap(x, wellKey_vector)

####to fix err in plot_dim_reduction################# library(data.table) library(ggplot2)

plot pca

plot_dt = data.table( y_var = label_vector ,dim1 = proj_umap$umap1 ,dim2 = proj_umap$umap2 ) col_vals = psupertime:::.make_col_vals(plot_dt$y_var) g = ggplot(plot_dt) + aes( x=proj_umap$umap1, y=proj_umap$umap2, colour=label_vector ) + geom_point() + scale_colour_manual( values=col_vals )

#####################################################

g = psupplementary:::plot_dim_reduction(label_vector, proj_umap$umap1, proj_umap$umap2, labels=c('umap1', 'umap2', 'Donor age (years)')) #err (g)

------------------------------------------------------------------------

run psupertime

message('running psupertime') y_age = acinar_sce$donor_age psuper_obj = psupertime(acinar_sce, y_age)

---- fig.show='hold', fig.height=4, fig.width=7, fig.cap="Sequential labels plotted over pseudotime values"----

plot labels over learned psupertime

message('plotting labels over psupertime') g = plot_labels_over_psupertime(psuper_obj, label_name) (g)

---- fig.show='hold', fig.height=8, fig.width=6, fig.cap="Diagnostic plot for checking that training worked well"----

plot training diagnostics

message('plotting psupertime training diagnostics') g = plot_train_results(psuper_obj) (g)

---- fig.show='hold', fig.height=6, fig.width=9, fig.cap="Expression profiles of relevant genes over pseudotime"----

plot identified genes against learned psupertime

########################IMPORTANT#################################### message('plotting identified genes over psupertime') g = plot_identified_genes_over_psupertime(psuper_obj, label_name) (g)

NOT RUN: smaller plot replicating Fig 1E

g = plot_identified_genes_over_psupertime(psuper_obj, label_name, n_to_plot=5)

---- fig.show='hold', fig.height=3, fig.width=6, fig.cap="Ordering coefficients of relevant genes"----

plot coefficients for identified genes

message('plotting identified gene coefficients') g = plot_identified_gene_coefficients(psuper_obj) (g)

------------------------------------------------------------------------

check whether can use topGO

if ( !requireNamespace("topGO", quietly=TRUE) ) { message('topGO not installed; not doing clustering') return() }

library('topGO') library(reshape2)

calculate go terms

go_list = psupertime_go_analysis(psuper_obj, org_mapping='org.Hs.eg.db')

mikashin avatar Mar 26 '24 14:03 mikashin