Questions tagged [permute]

permute is an R package for generating restricted permutations. Its original intention was for use with the vegan package to analyse multivariate models for ecological data.

permute is an R package that generates permutations from restricted designs, such as permutations within blocks. permute allows the following designs

  • Randomisation (free permutation)
  • Cyclic shifts for line transects and time series
  • Toroidal shifts for spatial grids

These can be nested hierarchically with samples present at 3 levels:

  • Block: these are never permuted, only samples within blocks are permuted.
  • Plot: Plots lie within Blocks. Plots may further restrict permutation (i.e. the plots are not permuted) or they may be permuted using any of the above 3 permutation types.
  • Within-plot: these are the samples at the lowest level, the individual rows of the data. These may be held fixed (within any Plots and/or Blocks) or be permuted following one of the three methods above)

This hierarchy allows for the testing of complex designs, including split-plot experimental designs.

68 questions
2
votes
1 answer

Why does the allPerms function in R always give one combination less?

I am trying to find all possible combinations for a number ie essentially the factorial of the number but also have display all possible combinations. When I use the allPerms function I am supposed to get all possible combinations but it gives…
RVRLibra
  • 63
  • 1
  • 12
2
votes
1 answer

Permute a list using Python

I have a list with the following elements: A,B,C,D,E,F,G. They are either suppose to true or false hence represented by 1 and 0 respectively. I am supposed to get a combinations but the following restrictions stay: Element C and Fare to be true in…
zcfaynh
  • 31
  • 4
2
votes
2 answers

How to calculate permutations of group labels with R?

Given a vector like: labels <- c(1,2,3,3,3) How to get all possible group relabelings? For this example: 1,2,3,3,3 1,3,2,2,2 2,1,3,3,3 2,3,1,1,1 3,1,2,2,2 3,2,1,1,1 I have been looking at the permute package but I don't see how to apply it to this…
alberto
  • 2,625
  • 4
  • 29
  • 48
1
vote
0 answers

Generate Random Permutations of Genomic Ranges using Nullranges (matchedranges or bootranges)

I want to generate 200 random genomicranges that are 200kbp long each that can occur anywhere in the genome. I was recommended to try using nullranges, but I haven't figured out how to specify only generating 200 ranges / iteration. I think it takes…
erman
  • 11
  • 1
1
vote
2 answers

How to combine pandas df so that rows with permuted col1 and col2 values can be merged containing only one combination & summing a count column

I want to combine the permuted col1 and col2 values into one row. containing only the first combination & summing the count column of both. Is there an easy way to do this in pandas? The example data frame and output: For example, in the below data…
chuchu
  • 13
  • 3
1
vote
1 answer

Permute a string by changing case (without affecting numbers)

I am trying to get all possible upper and lower case combinations from a given string, without affecting numbers in said string. I currently found this piece of code that works until you put a number into the sequence:
Crimin4L
  • 610
  • 2
  • 8
  • 23
1
vote
2 answers

Get the combination of 2 lists

I'm reposting this question because I was told that there is a solution for that in the last post. I have 2 lists: list1 = ["foo", "bar", "lorem"] list2 = ["X", "Y"] I want to have the possible combinations from these 2 lists, meaning: [["foo",…
1
vote
2 answers

Filter generated permutations in python

I want to generate permutations of elements in a list, but only keep a set where each element is on each position only once. For example [1, 2, 3, 4, 5, 6] could be a user list and I want 3 permutations. A good set would be:…
Qubix
  • 4,161
  • 7
  • 36
  • 73
1
vote
3 answers

Permutations with repetitions?

I can do this with itertools : list(permutations([1,2,3],2)) : [(1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2)] but how do I also generate : (1,1),(2,2),(3,3) of course w/o doing it separately : [(i,i) for i in range(4)]
sten
  • 7,028
  • 9
  • 41
  • 63
1
vote
1 answer

Defining permutation designs in "permute" R package

I'm having trouble accurately defining my permutation design/hierarchy in the "permute" package in R. Given a hypothetical set of plots, in which I've recorded species occurrences, I'd like to shuffle species within plots while maintaining the…
1
vote
3 answers

Transform (shuffle) just 2 Fields in a Dataframe

I have a data frame with firstname, lastname and I want to permutate them but ONLY for the rows that have values. There are many null fields and I don't want reorder them so that there is ever a firstname value without a lastname value.…
1
vote
1 answer

R. Compute product of value in row by permutated value of other column n times

I have a data frame like this (1000000 rows): A B C a 0.2 4 b 0.8 7 c 1 8 d 0.2 1 e 0.6 9 I would like to multiply each value in B by a random number taken from C (permutation without replacement) producing a new value…
Lucas
  • 1,139
  • 3
  • 11
  • 23
1
vote
2 answers

Permute labels of matrix while preserving the pairing of the samples

I have a matrix that's 490 rows (features; F1..F490) and 350 columns (350 samples; s1..s350). The first columns look like this: Drug T T T C T Sample s1 s2 s3 s4 s5 ..... Pair 16 81 -16 32 -81 ..... Cond B D B B D …
1
vote
2 answers

Alternative shorter method to permute and reshape a multidimensional-array

I have the following multidimensional array: a(:,:,1) = 11 12 13 21 22 23 a(:,:,2) = 21 22 23 31 32 33 a(:,:,3) = 31 32 33 41 42 43 The end result looks as follows: e = 11 21 …
Crysthius
  • 109
  • 2
  • 8
1
vote
0 answers

How to implement Aly's permutation test for comparison of variances in R?

The excerpt below is from "Permutation, Parametric and Bootstrap Tests of Hypotheses", Third Ed. by Phillip Good (pages 58-61), section 3.7.2.. I am trying to implement this permutation test in R (see further below) to compare two variances. I am…
Ramiro Magno
  • 3,085
  • 15
  • 30