Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rgsets does not support proper object "duplication" by value #46

Open
tetomonti opened this issue Jan 30, 2023 · 0 comments
Open

rgsets does not support proper object "duplication" by value #46

tetomonti opened this issue Jan 30, 2023 · 0 comments

Comments

@tetomonti
Copy link
Collaborator

When assigning a rgsets object to a new variable, this variable is only a reference to the old object, not a new one. Here is an example:

# genesets
genesets <- list(
  gset1=c("gene1","gene2","gene3"),
  gset2=c("gene4","gene5","gene6"),
  gset3=c("gene7","gene8","gene9"))
# nodes
nodes <- data.frame(row.names = unlist(genesets),label=unlist(genesets))
## some random edges
edges <- data.frame(
  from = gset1,
  to = gset3)

rgset1 <- hypeR::rgsets$new(genesets=genesets,nodes=nodes,edges=edges,name="test_geneset",version="1.0")

Now, if I assign that object (rgset1) to a new variable (rgset2):

> rgset2 <- rgset1
> rgset2$genesets

$gset1
[1] "gene1" "gene2" "gene3"

$gset2
[1] "gene4" "gene5" "gene6"

$gset3
[1] "gene7" "gene8" "gene9"

And I modify that object

> rgset2$genesets <- rgset1$genesets[1:2]
> rgset2$genesets
$gset1
[1] "gene1" "gene2" "gene3"

$gset2
[1] "gene4" "gene5" "gene6"

This also modifies the original object.

> rgset1$genesets
$gset1
[1] "gene1" "gene2" "gene3"

$gset2
[1] "gene4" "gene5" "gene6"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant