maftools icon indicating copy to clipboard operation
maftools copied to clipboard

Bug report with oncoplot and its potential cause

Open biosunsci opened this issue 3 years ago • 5 comments

Bug about the oncoplot relying function createOncoMatrix https://github.com/PoisonAlien/maftools/blob/eba7343b6d902f07c747869a315b9bd48b31341d/R/oncoplot.R#L88

When using oncoplot with parameter genes = c("some charactor vector") and fill = TRUE https://github.com/PoisonAlien/maftools/blob/af202ed5a590e87fdcc38b61ec559e8f4d235e11/R/oncomatrix.R#L29 the levels = g in this line will become unreliable especially when you pass the maf of oncoplot with a column named 'g'. The function now will use the 'g' column in the subMaf(in this case derived from laml) but not the argument of the function: https://github.com/PoisonAlien/maftools/blob/a62aa15ee561363615bf17d8d1fff3c9a7833d1e/R/oncomatrix.R#L1

I think this line is designed as subMaf[, Hugo_Symbol := factor(x = Hugo_Symbol, levels = {{ g }})] where the g refers to the parameter of the function createOncoMatrix but now it firstly refers to the column in the subMaf then refers to the parameter of the function if there is no column named 'g' in subMaf.

but unfortunately this code subMaf[, Hugo_Symbol := factor(x = Hugo_Symbol, levels = {{ g }})] does not work.

As I am a beginner of R, I don't know how to fix the bug. Please Help.

biosunsci avatar Nov 02 '21 11:11 biosunsci

@PoisonAlien, @ShixiangWang, Please Help with the R Grammar Problem~ How to refer to the function parameter rather than the column name in the dataframe manipulate sentence when they have the same name.

biosunsci avatar Nov 03 '21 01:11 biosunsci

@biosunsci Thanks for reporting and tagging me. I can reproduce this error with builtin laml data

The following code can fix this issue, @PoisonAlien Could you replace and check it in more details?

Replace subMaf[, Hugo_Symbol := factor(x = Hugo_Symbol, levels = g)] in line 29 with:

subMaf[, `:=`(Hugo_Symbol, factor(x = Hugo_Symbol, levels = get("g", envir = parent.env(environment()))))]

ShixiangWang avatar Nov 03 '21 02:11 ShixiangWang

@biosunsci Thanks for reporting and tagging me. I can reproduce this error with builtin laml data

The following code can fix this issue, @PoisonAlien Could you replace and check it in more details?

Replace subMaf[, Hugo_Symbol := factor(x = Hugo_Symbol, levels = g)] in line 29 with:

subMaf[, `:=`(Hugo_Symbol, factor(x = Hugo_Symbol, levels = get("g", envir = parent.env(environment()))))]

Thanks, that helped a lot ~ I'll close the issue when the code is updated.

biosunsci avatar Nov 03 '21 10:11 biosunsci

Hello @biosunsci , thanks for the issue and going through the code to investigate. @ShixiangWang as always, thanks for the solution :)

I am just thinking if this is the right way to address the issue. I will do a bit more digging and if nothing comes up, I will push the fix as described.

PoisonAlien avatar Nov 03 '21 13:11 PoisonAlien

Hello @biosunsci , thanks for the issue and going through the code to investigate. @ShixiangWang as always, thanks for the solution :)

I am just thinking if this is the right way to address the issue. I will do a bit more digging and if nothing comes up, I will push the fix as described.

Thanks a lot, @PoisonAlien, when the code is settled, please let me know, I'll close the issue then.

biosunsci avatar Nov 04 '21 01:11 biosunsci

This issue is stale because it has been open for 60 days with no activity.

github-actions[bot] avatar Aug 25 '23 01:08 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Sep 08 '23 01:09 github-actions[bot]