将两个数组(逐列)合并到perl中的新复合数组中的方法是什么?
@数组1
car
scooter
truck
Run Code Online (Sandbox Code Playgroud)
@数组2
four
two
six
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下内容:
my @merged = (@array1, @array2); print @merged;
Run Code Online (Sandbox Code Playgroud)
但它将两个数组合并在一列中,如下所示:
car
scooter
truck
four
two
six
Run Code Online (Sandbox Code Playgroud)
但我想要的是如下:
@merged[0] @merged[1]
car four
scooter two
truck six
Run Code Online (Sandbox Code Playgroud) 我需要使用 igraph 从图 (g) 中获取种子节点的子图(节点的输入列表;file.txt)及其第一个交互器(邻居)。不幸的是,我最终在子图中只有一个节点,而不是所有其余的节点和连接它们的边(顶点)。
g<-read.graph("DATABASE.ncol",format="ncol",directed=FALSE) #load the data
g2<-simplify(g, remove.multiple=TRUE, remove.loops=TRUE) # Remove the self-loops in the data
DAT1 <- readLines("file.txt") #It provides a character vector right away
list_nodes_1 = neighbors(g2, DAT1) #list of nodes to be fetched in subnetwork
list_nodes_1 # 16
g3 <- induced.subgraph(graph=g2,vids=DAT1) #subnetwork construction
g3 # GRAPH UN-- 1 0 --; indicating only one node
plot (g3)
Run Code Online (Sandbox Code Playgroud)
获取整个子网(包括节点和顶点)的任何建议?或者是否有任何其他功能可用于创建子图?
数据库.ncol:
MAP2K4 FLNC
MYPN ACTN2
ACVR1 FNTA
GATA2 PML
RPA2 STAT3
ARF1 GGA3
ARF3 ARFIP2
ARF3 ARFIP1 …Run Code Online (Sandbox Code Playgroud) 我有如下数据:
RNA$MMP2
[1] 1.506000000 0.957833333 2.285500000 -0.089333333 -1.233166667
[6] 1.591500000 -1.396500000 -0.260500000 0.583000000 -0.716333333
[11] 1.628833333 -0.390000000 -0.466166667 -0.550666667 1.001666667
[16] 1.399000000 -0.454500000 -0.492833333 0.695166667 0.397666667
Run Code Online (Sandbox Code Playgroud)
如果我要根据某个阈值(例如 1.0)用字符变量替换这些数字变量,我会实现以下内容:
ifelse(RNA$MMP2 <= 1.0 ,"low","high")->x
Run Code Online (Sandbox Code Playgroud)
如果我需要分类为三个字符变量怎么办:
a) RNA$MMP2 < 0.5 ,"low";
b) RNA$MMP2 > 0.5 and < 1.0, "medium";
c) RNA$MMP2 > 1.0, "high";
Run Code Online (Sandbox Code Playgroud)
建议将不胜感激。
我正在尝试grep使用以下代码在Perl中:
my @S = grep /M1A3B6/, @AR3;
print @S;
Run Code Online (Sandbox Code Playgroud)
但是,grep通过循环没有返回任何值.
for(my $j=0; $j<$ln1; $j++){
@S = grep /$AR1[$j]/, @AR3;
$j++;
}
print @S;
Run Code Online (Sandbox Code Playgroud)
示例文件如下:
@AR1
M1A3B6
M1AZ83
@AR3
>tr|M1A3B6|Uncharacterized protein >>MFNLHLLAVG
>tr|M1AP92|Uncharacterized protein >>MQTLSRAQSQ
>tr|M1AZ83|Uncharacterized protein >>MASFTTLTSLFFFF
Run Code Online (Sandbox Code Playgroud)
所有建议将不胜感激.