I wish to compare variables for patients with, and without, a certain mutation. The data is non-parametric.

I have assessed if there is a significant difference for each variable e.g. serum potassium by doing Mann-Whitney-U tests (called two-sample Wilcoxon test on R), with the wilcox.test() function.

I would like to also report the difference of the medians with confidence intervals (alongside the p-value for Mann-Whitney-U).

Note the wilcox.test() function reports confidence intervals of the median of the differences, which is not the same thing.

I have tried - and failed - using the twomeans() function with the dplyr package, and also the median.diff() function in the pairwiseCI package.

I must preface with the disclaimer that, in essence, I don't know what I'm talking about in the world of nonparametric statistics, among many other universes. So let me be the slave boy at the Symposium.

You have a series of paired medians and their differences, and you want to be able to bracket the confidence intervals around the differences, if I've understood the question.

Do you have to have a distribution model in mind to calculate the CIs? Let D = difference(obs_1 - obs_2) .Is D random (goody, normal), or one of the other standard distributions? If it's an exotic distribution, which one? If indeterminate, how will it ever be possible ever to put CI around it?

All of which is to say, I have only a question, not an answer.

I'm glad to be a tabula rasa interlocutor on the problem, if that helps.

Since OP specifically mentions "The data is non-parametric.", I think nothing is known about the underlying distribution, except continuity. But I agree with Richard that this is a valid question.

Usually for pairwise data, Wilcoxon test converts two sample data to a one sample data of differences and check whether median of that distribution is 0 or not. If one finds the median of the two samples separately, and even if we assume that large sample approximations to distributions of sample medians are valid, how does one consider the dependence of the two samples? If the samples are independent, that's OK, but that's very unlikely considering the context of the problem.

I don't think dplyr has a function twomeans. And, please keep in mind R is case sensitive, the function in pairwiseCI is Median.diff, not median.diff.

Yes, I do know that the underlying data is non-parametric. I don't understand why that make medians derived from the data non-parametric, as well. Consider the classic flights database in the nycflights13 library. Let arr_delay represent the difference in medians and arbitrarily model it on dep_time + distance.

To clarify:
For those data in my dataset that are normally distributed, I have been able to calculate the difference in means, with corresponding p-values (t-test) and confidence intervals.
I had (naively) hoped to do the same for my ab-normal variables - mostly to fill empty gaps in the table I am compiling. I now see it is more complicated than that! I have no idea what distribution these variables are, only that the qqplots are a poor fit (so not normal).
Maybe it's a non-starter.