Issue while drawing an haplotype network using {pegas}
I am trying to produce a haplotype network using pegas. I managed to do the basic network, but when I try to add slices of different color to each "pie" I can't seem to move forward.
I will replicate my error using the the woodmouse dataset:
data(woodmouse)
x <- woodmouse[sample(15, size = 110, replace = TRUE), ]
h <- haplotype(x)
net <- haploNet(h)
plot(net, size=attr(net, "freq"), scale.ratio = 2, cex = 0.8)
ind.hap<-with(
stack(setNames(attr(h, "index"), rownames(h))),
table(hap=ind, pop=rownames(x)[values])
)
With the above code I manage to plot the network no problem, but when I try to execute the last four lines of code I get the following error:
ind.hap<-with(
stack(setNames(attr(h, "index"), rownames(h))),
table(hap=ind, pop=rownames(x)[values])
)
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘raster’ for signature ‘"integer"’
Any suggestion on what might be the problem?
r dna-sequence phylogeny genetics
add a comment |
I am trying to produce a haplotype network using pegas. I managed to do the basic network, but when I try to add slices of different color to each "pie" I can't seem to move forward.
I will replicate my error using the the woodmouse dataset:
data(woodmouse)
x <- woodmouse[sample(15, size = 110, replace = TRUE), ]
h <- haplotype(x)
net <- haploNet(h)
plot(net, size=attr(net, "freq"), scale.ratio = 2, cex = 0.8)
ind.hap<-with(
stack(setNames(attr(h, "index"), rownames(h))),
table(hap=ind, pop=rownames(x)[values])
)
With the above code I manage to plot the network no problem, but when I try to execute the last four lines of code I get the following error:
ind.hap<-with(
stack(setNames(attr(h, "index"), rownames(h))),
table(hap=ind, pop=rownames(x)[values])
)
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘raster’ for signature ‘"integer"’
Any suggestion on what might be the problem?
r dna-sequence phylogeny genetics
That did it, thanks MrFlick. I guess there was a conflict with other packages, likely raster. Cheers
– Cinghio
Nov 16 '18 at 15:14
add a comment |
I am trying to produce a haplotype network using pegas. I managed to do the basic network, but when I try to add slices of different color to each "pie" I can't seem to move forward.
I will replicate my error using the the woodmouse dataset:
data(woodmouse)
x <- woodmouse[sample(15, size = 110, replace = TRUE), ]
h <- haplotype(x)
net <- haploNet(h)
plot(net, size=attr(net, "freq"), scale.ratio = 2, cex = 0.8)
ind.hap<-with(
stack(setNames(attr(h, "index"), rownames(h))),
table(hap=ind, pop=rownames(x)[values])
)
With the above code I manage to plot the network no problem, but when I try to execute the last four lines of code I get the following error:
ind.hap<-with(
stack(setNames(attr(h, "index"), rownames(h))),
table(hap=ind, pop=rownames(x)[values])
)
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘raster’ for signature ‘"integer"’
Any suggestion on what might be the problem?
r dna-sequence phylogeny genetics
I am trying to produce a haplotype network using pegas. I managed to do the basic network, but when I try to add slices of different color to each "pie" I can't seem to move forward.
I will replicate my error using the the woodmouse dataset:
data(woodmouse)
x <- woodmouse[sample(15, size = 110, replace = TRUE), ]
h <- haplotype(x)
net <- haploNet(h)
plot(net, size=attr(net, "freq"), scale.ratio = 2, cex = 0.8)
ind.hap<-with(
stack(setNames(attr(h, "index"), rownames(h))),
table(hap=ind, pop=rownames(x)[values])
)
With the above code I manage to plot the network no problem, but when I try to execute the last four lines of code I get the following error:
ind.hap<-with(
stack(setNames(attr(h, "index"), rownames(h))),
table(hap=ind, pop=rownames(x)[values])
)
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘raster’ for signature ‘"integer"’
Any suggestion on what might be the problem?
r dna-sequence phylogeny genetics
r dna-sequence phylogeny genetics
asked Nov 15 '18 at 21:45
CinghioCinghio
4018
4018
That did it, thanks MrFlick. I guess there was a conflict with other packages, likely raster. Cheers
– Cinghio
Nov 16 '18 at 15:14
add a comment |
That did it, thanks MrFlick. I guess there was a conflict with other packages, likely raster. Cheers
– Cinghio
Nov 16 '18 at 15:14
That did it, thanks MrFlick. I guess there was a conflict with other packages, likely raster. Cheers
– Cinghio
Nov 16 '18 at 15:14
That did it, thanks MrFlick. I guess there was a conflict with other packages, likely raster. Cheers
– Cinghio
Nov 16 '18 at 15:14
add a comment |
1 Answer
1
active
oldest
votes
The error message sounds like it's coming from the stack()
function from the raster
package rather than the base stack()
function. Packages can both define functions with the same name; R will find the one from the most recently loaded package. To use the version from utils
, you can prefix it with the namespace and ::
. For example
utils::stack(setNames(attr(h, "index"), rownames(h)))
That should solve the problem.
Thanks thats a good answer
– Michael G.
Nov 26 '18 at 18:44
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53328342%2fissue-while-drawing-an-haplotype-network-using-pegas%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The error message sounds like it's coming from the stack()
function from the raster
package rather than the base stack()
function. Packages can both define functions with the same name; R will find the one from the most recently loaded package. To use the version from utils
, you can prefix it with the namespace and ::
. For example
utils::stack(setNames(attr(h, "index"), rownames(h)))
That should solve the problem.
Thanks thats a good answer
– Michael G.
Nov 26 '18 at 18:44
add a comment |
The error message sounds like it's coming from the stack()
function from the raster
package rather than the base stack()
function. Packages can both define functions with the same name; R will find the one from the most recently loaded package. To use the version from utils
, you can prefix it with the namespace and ::
. For example
utils::stack(setNames(attr(h, "index"), rownames(h)))
That should solve the problem.
Thanks thats a good answer
– Michael G.
Nov 26 '18 at 18:44
add a comment |
The error message sounds like it's coming from the stack()
function from the raster
package rather than the base stack()
function. Packages can both define functions with the same name; R will find the one from the most recently loaded package. To use the version from utils
, you can prefix it with the namespace and ::
. For example
utils::stack(setNames(attr(h, "index"), rownames(h)))
That should solve the problem.
The error message sounds like it's coming from the stack()
function from the raster
package rather than the base stack()
function. Packages can both define functions with the same name; R will find the one from the most recently loaded package. To use the version from utils
, you can prefix it with the namespace and ::
. For example
utils::stack(setNames(attr(h, "index"), rownames(h)))
That should solve the problem.
answered Nov 16 '18 at 16:12
MrFlickMrFlick
124k11141171
124k11141171
Thanks thats a good answer
– Michael G.
Nov 26 '18 at 18:44
add a comment |
Thanks thats a good answer
– Michael G.
Nov 26 '18 at 18:44
Thanks thats a good answer
– Michael G.
Nov 26 '18 at 18:44
Thanks thats a good answer
– Michael G.
Nov 26 '18 at 18:44
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53328342%2fissue-while-drawing-an-haplotype-network-using-pegas%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
That did it, thanks MrFlick. I guess there was a conflict with other packages, likely raster. Cheers
– Cinghio
Nov 16 '18 at 15:14