decoupler.pp.shuffle_net#

decoupler.pp.shuffle_net(net, target=True, weight=False, seed=42, same_seed=True)#

Shuffle a network to make it random.

Shuffle a given net by targets, weight or both at the same time.

If only targets are shuffled, targets will change but the distribution of weights for each set will be preserved.

If only weights are shuffled, targets will be the same but the distribution of weights for each set will change.

If targets and weights are shuffled at the same time, both targets and weight distribution will change for each set.

Parameters:
net DataFrame

Dataframe in long format. Must include source and target columns, and optionally a weight column.

target bool (default: True)

Whether to shuffle targets.

weight bool (default: False)

Whether to shuffle weights.

seed int (default: 42)

Random seed to use.

same_seed bool (default: True)

Whether to share seed when shuffling targets and weights.

Return type:

DataFrame

Returns:

Shuffled network.

Example

import decoupler as dc

adata, net = dc.ds.toy()
rnet = dc.pp.shuffle_net(net)
rnet