Skip to main content
8 votes
Accepted

How to do `bedtools intersection` using pandas alone?

Your setup: ...
The Unfun Cat's user avatar
6 votes
Accepted

Possibility to save output blastn table in memory using biopython

You can specify send to stdout using out='-' in the Biopython wrapper. ...
zorbax's user avatar
  • 769
4 votes

How to do `bedtools intersection` using pandas alone?

I don't think Pandas has this implemented functionality out-of-the-box. Even if it did, solutions not designed specifically for bioinformatics probably rarely handle intervals on different chromosomes ...
Daniel Standage's user avatar
4 votes

Math on Pandas Columns

The vectorised solution (fast) is, ...
M__'s user avatar
  • 12.5k
3 votes

To create a new column with Pandas on the basis of two types of column values

To elaborate on this answer, here is a full working example where I assume that "BARCODE", "ANCHOR_NAME" and ...
bli's user avatar
  • 3,130
3 votes
Accepted

To create a new column with Pandas on the basis of two types of column values

You can use groupby() as following : ...
TUI lover's user avatar
  • 146
3 votes

How to do `bedtools intersection` using pandas alone?

As mentioned by OP, another option is to use pybedtools, which in my opinion is pretty convenient for people already familiar with BedTools. Let's even say df1's format is slightly different than df2: ...
Kapara newbie's user avatar
3 votes
Accepted

How to fix the Error in Kruskal Wallis rank sum test for comparing the guides in python? Also to check whether using the right test for my data?

Reformatting the data for the KW and doing the test is easy. Using "guide_1" alone and pivot() to get A = [1, 0.426115 ... ...
M__'s user avatar
  • 12.5k
3 votes
Accepted

How can I use pandas agg here to avoid iteration?

...
The Unfun Cat's user avatar
3 votes
Accepted

Tidying MEGAN Taxonomy for Python/R Analysis

Save the following as a python script (e.g., named splitty.py). Make the script executable by doing chmod +x splitty.py. Then, ...
user3479780's user avatar
3 votes
Accepted

Getting rid of duplicates in a dictionary

Not sure how you'd do this in python but you need a group-by operation here. Group by the read name and pick the min length per group. EDIT: With pandas, you can do: ...
Ram RS's user avatar
  • 2,330
2 votes

How to do `bedtools intersection` using pandas alone?

I implemented pandas "Intervals" and ... it should be a few lines, clearly there are limitations. For non-overlapping data it is very cool however. It will work for overlapping data, BUT if the data ...
M__'s user avatar
  • 12.5k
2 votes
Accepted

Adding multiple dataframes to compare against genotypes - DATE/LOCATION - geotemporal incidences of SARS2 genotypes

Just to clarify, when I asked you to share some of your files, I meant to share them in a way that I can reproduce your issue from start to finish. You read from at least four different files in a ...
Bastian Schiffthaler's user avatar
2 votes
Accepted

Converting hmmer --tblout to pandas dataframe

The manual says fields in a tabular output file are space-delimited. It should be fairly straightforward to load a space-delimited file in pandas. From the manual: ...
Ram RS's user avatar
  • 2,330
2 votes
Accepted

How to get separate histograms plots on the basis of the column value?How to detect which plot has most deviation?

You could use the groupby() pandas function to group the dataframe by gene name. And then just loop through each group to plot the histogram of correlation values. I think you can use the mean of the ...
Steve's user avatar
  • 3,109
2 votes
Accepted

Merge the dataframes with python iterator

Its a simple join operation. ...
M__'s user avatar
  • 12.5k
2 votes
Accepted

Help to create a dataframe in Python from a FASTA file

Assuming what I said in the comments is true. Here's my attempt, there may be an easier solution but this should do it: ...
user324810's user avatar
  • 1,125
2 votes
Accepted

calculating mutation frequencies for every gene

The code is fine. The only issue is you'd put \s characters in-between the column header names. I've place an additional "mutation_frequency" column because thats how I'd do it. ...
M__'s user avatar
  • 12.5k
2 votes
Accepted

expansions and contractions from OrthoFinder

The answer is actually right there in the error message (warning message, actually): DtypeWarning: Columns (2,... 968) have mixed types. Specify dtype option on import or set low_memory=False. ...
terdon's user avatar
  • 10.2k
2 votes

How to run python request for list of url's with multiple page numbers?

@Megha The requestIt(link) function returns a list of dictionary objects. So your "data" variable is a list of dictionary objects. Every item on this list (a dict) has a key named "...
punxx's user avatar
  • 21
2 votes
Accepted

How to calculate frequency of a category with respect to the value in another column?

I am not able to reproduce the issue. However I think this is a crosstab problem: ...
Maximilian Press's user avatar
2 votes

Getting rid of duplicates in a dictionary

You can do this with the sort command-line tool. This command pipe sequence sorts numerically by the second field, then chooses unique elements based on the first ...
gringer's user avatar
  • 14.3k
2 votes

ValueError: count not convert string to float

Ah! I finally got it to work! I used your command but I had to change it up a little bit to work with my data. The final command I used is this: ...
rimo's user avatar
  • 1,003
1 vote
Accepted

How to run python request for list of url's with multiple page numbers?

Okay, its done. What you are looking for is as follows: ...
M__'s user avatar
  • 12.5k
1 vote

How to run python request for list of url's with multiple page numbers?

@Megha, I have not looked through the code in too much detail, however. obo = obj["obo_id"] for obj in data This isn't formal Python code. The correction ...
M__'s user avatar
  • 12.5k
1 vote
Accepted

Automate the def function in pandas for correlation

If I have understood the question is to generalise the column names to permit a function to accept dataframes where you don't have the same column name, or it's different from the previous dataframe ...
M__'s user avatar
  • 12.5k
1 vote
Accepted

Python list comprehension to calculate the set of categories for each row

What I'm not clear about is the definition of y - thats crucial to understanding what the code does. Just to note, although you've called the dataframe ...
M__'s user avatar
  • 12.5k
1 vote

expansions and contractions from OrthoFinder

The error right at the end is Specify dtype option on import or set low_memory=False. Edit Oh wait @terdon has already spotted ...
M__'s user avatar
  • 12.5k
1 vote

Help to create a dataframe in Python from a FASTA file

An example of contructing a pandas dataframe for fasta on Stack Exchange is here . This is clean code deploying zip outside Biopython. Constructing a pandas ...
M__'s user avatar
  • 12.5k
1 vote

Merge data frame on either of the 2 columns in R or python

I think this question is more about subsetting than merging. You can try this solution in R: ...
Nitesh Shriwash's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible