小编liz*_*eta的帖子

Extract column name and match with another column

I have a dataframe MutationsNumberTable like this

    ACC BLCA BRCA CESC   HGNC
1:   1    2    6    0   OPN4
2:   2    3    1    1  KLRB1
3:   2   23    4    5  SALL2
4:   1    8    5    7  PLCB2
Run Code Online (Sandbox Code Playgroud)

The goal is to create a matrix where I have unique pairs "gene-cancer type" where a number in a table is greater than a threshold (let's say, 5):

Desired output:

     HGNC Cancer
1:   OPN4 CESC
2:   SALL2 BRCA
3:   SALL2 CESC
4:   PLCB2 BLCA …
Run Code Online (Sandbox Code Playgroud)

filtering r

3
推荐指数
1
解决办法
39
查看次数

如何从Python中所有组合列表中的索引了解元素的组合

我有一些列表中的所有对组合:

a = [1,2,3,4,5,6]
pairs = [pair for pair in itertools.combinations(a,2)]
print pairs

>>>[(1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 5)]
Run Code Online (Sandbox Code Playgroud)

如果我只知道它的索引,我如何知道我到底在使用哪个对?也许有一些公式?问题是我的列表太大了,我无法记住所有对。我只需要一些可以通过索引识别的特定对。

有什么建议么?

谢谢!

python combinations python-itertools

2
推荐指数
1
解决办法
608
查看次数

当start大于stop时如何生成序列

我想生成类似于10, 7, 4, 1

seq函数无法做到这一点(开始大于停止)。什么函数可以做到这一点?我不喜欢循环我的序列(这将非常耗时,因为我需要像这样处理大量向量)。

> seq(10, 0, by=3)
Run Code Online (Sandbox Code Playgroud)

seq.default(10, 0, by = 3) 中的错误:“by”参数中的符号错误

r vector seq

2
推荐指数
1
解决办法
218
查看次数

标签 统计

r ×2

combinations ×1

filtering ×1

python ×1

python-itertools ×1

seq ×1

vector ×1