Issue while drawing an haplotype network using {pegas}












1















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?










share|improve this question























  • That did it, thanks MrFlick. I guess there was a conflict with other packages, likely raster. Cheers

    – Cinghio
    Nov 16 '18 at 15:14
















1















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?










share|improve this question























  • That did it, thanks MrFlick. I guess there was a conflict with other packages, likely raster. Cheers

    – Cinghio
    Nov 16 '18 at 15:14














1












1








1


1






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?










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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



















  • 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












1 Answer
1






active

oldest

votes


















2














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.






share|improve this answer
























  • Thanks thats a good answer

    – Michael G.
    Nov 26 '18 at 18:44











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
});


}
});














draft saved

draft discarded


















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









2














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.






share|improve this answer
























  • Thanks thats a good answer

    – Michael G.
    Nov 26 '18 at 18:44
















2














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.






share|improve this answer
























  • Thanks thats a good answer

    – Michael G.
    Nov 26 '18 at 18:44














2












2








2







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 16 '18 at 16:12









MrFlickMrFlick

124k11141171




124k11141171













  • 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





Thanks thats a good answer

– Michael G.
Nov 26 '18 at 18:44




















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python